Generating rows
Hello
This is probably quite straight forward but it's monday morning and my brain hurts...
I have the following table
create table dt_test_dates(id number, eff_date date,ret_month number,ret_day number);
insert into dt_test_dates values(1,to_date('01/01/2000','dd/mm/yyyy'),3,15);
insert into dt_test_dates values(2,to_date('01/01/2000','dd/mm/yyyy'),9,10);
insert into dt_test_dates values(3,to_date('01/01/2000','dd/mm/yyyy'),8,9);I need to generate a date for each year between the eff_date and the current sysdate, on the ret_month and ret_day i.e.
ID Date
1 15/03/2000
1 15/03/2001
1 15/03/2002
1 15/03/2003
1 15/03/2004
1 15/03/2005
2 09/10/2000
2 09/10/2001
2 09/10/2002
2 09/10/2003
2 09/10/2004
2 09/10/2005
3 08/09/2000
3 08/09/2001
3 08/09/2002
3 08/09/2003
3 08/09/2004
3 08/09/2005I generated a pipelined function to generate the dates based on the above criteria but I can't see how to fit it into an sql query to pass the ret_month and re_day for each row in dt_test_dates.
I need to use the output of this statement as part of a subquery for the main SQL statement.
Can anyone help?
David
Invoking pipelined functions is not always obvious, as you've discovered ! Anyway, you basically create a cartesian product as follows:-
SELECT dt.id, ed.column_value
FROM dt_test_dates dt
, TABLE( expand_dates( dt.eff_date, dt.ret_month, dt.ret_day ) ) ed;The reason it is not obvious is because you can pass the columns of the DT table as arguments to the pipelined function, which seems counter-intuitive at first, but is similar to the TABLE usage for nested tables in columns. Anyway, here is my implementation of expand_dates:-
CREATE TYPE date_ntt AS TABLE OF DATE;
CREATE FUNCTION expand_dates (
start_date_in IN DATE,
ret_month_in IN NUMBER,
ret_day_in IN NUMBER
) RETURN date_ntt PIPELINED AS
v_year INTEGER := EXTRACT( YEAR FROM start_date_in );
v_year_end INTEGER := EXTRACT( YEAR FROM SYSDATE );
v_date DATE := ADD_MONTHS( start_date_in, ret_month_in-1 ) + ( ret_day_in-1 );
BEGIN
WHILE v_year <= v_year_end LOOP
PIPE ROW ( v_date );
v_date := ADD_MONTHS( v_date, 12 );
v_year := EXTRACT( YEAR FROM v_date );
END LOOP;
RETURN;
END expand_dates;You might want some NVLs depending on your preferences and your data.
Regards
Adrian
Similar Messages
-
Unpivot task is generating rows for null inputs
So I have a C# application (VS 2012 with .NET4.5) that builds SSIS (SQL2012) packages programatically. the packages can be opened in the designer and they run fine. However, there is one case that is giving me a problem. I have an
OleDb source connected to a table in SQL server. I am using the unpivot task to convert columns in a sparse matrix to an Entity Attribute Value model. So basically, the primary key value of the source table is a pass-through value in the unpivot
task, each column is mapped to the destination column, and the attribute id is hard coded as the pivot key. Like i said this works great EXCEPT i came across one column and a table that was null for all the rows in the table. when I run the package,
it fails with:
OnError,SERVERNAME,DOMAIN\user,{94E83A3B-5386-4712-BEDC-11E35341675F},{94E83A3B-5386-4712-BEDC-11E35341675F},{3187347C-8D44-4D51-8FDB-B5C4159A58B0},9/14/2012 9:48:02 AM,9/14/2012 9:48:02 AM,-1071607780,0x,There was an error with OLE DB Destination.Inputs[OLE
DB Destination Input].Columns[AttributeId] on OLE DB Destination.Inputs[OLE DB Destination Input]. The column status returned was: "The value violated the integrity constraints for the column."
So I set up a data viewer on the data flow and found that the unpivot component was generating rows for every null value. not only that, but the values for the key column and the attribute id (which was hard coded) were also null for all the rows
sent from the unpivot to the ole db destination. I manually created a package with an unpivot for just the column in question and got the same result. then I inserted a value for every row in the table and the same package runs fine.
can someone offer any help or advice on what might be causing this?its just two columns of data that are concerned. ten character numeric strings in the one and null in the other. the pivot key is hard coded in the unpivot component configuration screen. see the output of the data viewer below. How do
I get Microsoft involved with this?
2013399057 NULL
2013399488 NULL
2013399770 NULL
2013402244 NULL
2013402440 NULL
2013404066 NULL
2013404070 NULL
2013404203 NULL
2013404206 NULL
2013404401 NULL
2013404589 NULL
2013404705 NULL
2013404738 NULL
2013404768 NULL
2013404784 NULL
2013404813 NULL -
How to generate row numbering over several pages in PAGES??
How can I generate row numbering over several pages in PAGES??
e.g. Page1 1-35
Page2 36-...Hi Labrat,
My suggestion would be to create a Template in the Page Layout mode. This template would have a 1-column Table to present the line numbers and a Text Box for the Body Text. If you want the Line Numbers to stay in alignment with the Body Text, set the spacing for both to Exactly. Set the Table Cell Borders to None. The faint cell borders that you see in the following example are there because I am in View Layout mode. They will not show when printed.
For my example I have used Format > Advanced > Capture Pages to create a Pull-down +Page option for a Numbered Line Page. You can Capture as many versions of your numbered pages as you like to avoid having to modify the Line Numbers on successive pages.
Here's my example:
Regards,
Jerry
Message was edited by: Jerrold Green1 -
OWB use unwanted RTRIM in generated row based code
Hi everybody,
In a pretty straightforward mapping with simple DELETE and then INSERT OWB generate row based code. This would not bother me too much but in INSERT statement OWB use TRIM for all character columns immediately converting fields with spaces into NULL which I badly need to avoid. Does anybody know if this is OWB feature or is it configurable and can be avoided?
I would appreciate any suggestions,
AlexThere are more than one way you can do this. Put it in the pre-mapping process, as described by you, use an expression, use a trasformation or use a temporary table to store constant values calculated on the fly. It all depends on what exacltly you want to do and on your environment details.
Regards:
Igor -
Get generated rows by Spry with jQuery
i have a spry region like this
<table class="widget-elenco">
<tr spry:repeat="pv" spry:even="even" spry:odd="odd">
<td>{soggetto_id}</td>
<td>{codice_fiscale}</td>
<td>{partita_iva}</td>
</tr>
</table>
the problem: i cant' get the generated rows by spry:repeat with jquery
i try with an observer, something like this
var myObserver = function(nType, notifier, data){
if (nType == 'onPostLoad') {
$(function(){
$('table.widget-elenco tr').each(function() {
doSomething()
ds.addObserver(myObserver);
but this not woks :-/
i can to change "onPostLoad" to "onPreLoad" or "onDataChanged"
without solutions :-/
any idea?
many thanks!
Robhi gramps :-)
thanks for your reply!
here:
http://qubica.in/manager/soggetti/index.cfm
simple: i would "remove" the anti-estetic "onmouseover/onmouser" function added on a single <tr> for replace with a jquery function:
$(function(){
$('table.widget-elenco tbody tr').mouseover(function() {
$(this).addClass('ui-state-highlight');
}).mouseout(function() {
$(this).removeClass('ui-state-highlight');
yes, this is not a so important problem... :-) but, in general, the *REAL* question is "how do i get generated rows... using jQuery selector?"
something lijke this:
$(function(){
$('ELEMENTS-IN-SPRY-REGION').each(function() {
doSomethings();
thanks!
Rob -
How to handle newly generated rows values?
Hi all,
My requirement is to generate rows after output is generated.I am able to generate the rows .But my problem is user can generate multiple empty rows.Suppose he generated 2 empty rows .After generating those 2 empty rows.In the first newly generated row he will select one value help.My problem is that data_change event is trigerring when that f4 help is populated.After that I select the value from f4 help and goes to the second newly generated row and again does the same thing.Now my requirement is for these 2 lands,I want to pick up all the available tests from the database table for these 2 lands and display in the grid.There may be multiple tests available for each land in the database table.
I am getting wrong values in the data_changed method.Can I use handle_data_changed_finished event for this.I am not able to catch the absolute values using data_change event.
Can any one help in this regard?
Thanks,
BalajiHi Gaurav,
Thanks for the replay , here for table switcher how can we differienciate between the message text and lov ,to capture lov values i have searched alot, here is my code.
In process from request.
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(oawebbean);
OATableBean tb = (OATableBean)oawebbean.findIndexedChildRecursive("EamRetMaterialToInvDetail");
OASwitcherBean SwitcherRN=(OASwitcherBean)oawebbean.findChildRecursive("EamMaterial");
if(SwitcherRN!=null)
// id EamAddNewMaterial
if (pageContext.getParameter("EamAddNewMaterial")!=null)
if(pageContext.isLovEvent())
if("lovValidate".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)) || "lovUpdate".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))||"lovPrepare".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
String lovInputSourceId = (String)pageContext.getLovInputSourceId();
if("EamMaterialName".equals(lovInputSourceId))
/*String workorderID = null;
String lovInput = (String) lovBean.getValue(pageContext);
OAMessageLovInputBean lovBean=(OAMessageLovInputBean)oawebbean.findChildRecursive("EamMaterialName"); */
// pageContext.writeDiagnostics(this,"After : "+pageContext.getParameter("EamAddNewMaterial"),4);
pageContext.writeDiagnostics(this, "Vamsi: LOV caught", 4);
Can you please sugget me -
How to generate rows in SQLPLUS ?
Hi,
Suppose, I have data like this in Oracle 9.2
200, 74001, 74010, 1, 3, 4
I want output like this
200,74001,1
200,74001,3
200,74001,4
200,74002,1
200,74002,3
200,74002,4
200,74010,1
200,74010,3,
200,74010,4
How can I generate these rows in SQLPLUS ? Can it be possible using connect by ?
thanks & regards
paragAnd a version which don't supresses the »74010« row (but assumes 10g):
SQL> with t as
select 200 col1, 74001 col2, 74010 col3, 1 col4, 3 col5, 4 col6 from dual
select * from xmltable('for $i in ROWSET/ROW for $j in xs:integer($i/COL2/text()) to xs:integer($i/COL3/text())
return for $k in 1 to 3
return <r><i>{$i/COL1/text()}</i><j>{$j}</j><k>{$i/*[$k+3]/text()}</k></r>'
passing xmltype(cursor(select * from t))
columns col1 integer path 'i',
col2 integer path 'j',
col3 integer path 'k')
COL1 COL2 COL3
200 74001 1
200 74001 3
200 74001 4
200 74002 1
200 74002 3
200 74002 4
200 74003 1
200 74003 3
200 74003 4
200 74004 1
200 74004 3
200 74004 4
200 74005 1
200 74005 3
200 74005 4
200 74006 1
200 74006 3
200 74006 4
200 74007 1
200 74007 3
200 74007 4
200 74008 1
200 74008 3
200 74008 4
200 74009 1
200 74009 3
200 74009 4
200 74010 1
200 74010 3
200 74010 4
30 rows selected. -
Table Maintenance Generator - Rows should be editable
Hi
I have created one TMGfor a database table. In that im having two screens one is overview & other is single screen. based on the requirement i have changed the second screen that means single screen. There I have put one table control and copy paste the first screens code here.
Here im facing one problem. When im clicking on New Entries it will move on to second screen but only 8 rows are in editable mode. I want all the rows should be in editable. The problem is first screen that means overview screen has 8 entries and that many rows are in editable mode in second screen.
Please help me.Hi,
In PBO of the single screen, there will be a variable which stores number of records to be edited.
By debugging try to find out that variable and change its value to number of records in the
output internal table..
Expecting that variable name will have a pattern as maxlines*. -
Generate rows base on complex logic
hi, i have a complex scenario that i am trying to solve. i will appreciate any help out there.
consider the following data.
WITH table1 AS
SELECT 111 cid, 200 amt, 'P' ind FROM dual UNION all
SELECT 111 cid, 200 amt, 'S' ind FROM dual UNION ALL
SELECT 111 cid, 20 amt, 'AC' ind FROM dual UNION ALL
SELECT 111 cid, 80 amt, 'S' ind FROM dual UNION ALL
SELECT 222 cid, 100 amt, 'P' ind FROM dual UNION all
SELECT 222 cid, 100 amt, 'S' ind FROM dual UNION ALL
SELECT 222 cid, 20 amt, 'AC' ind FROM dual UNION ALL
SELECT 333 cid, 300 amt, 'P' ind FROM dual UNION all
SELECT 333 cid, 300 amt, 'S' ind FROM dual UNION ALL
SELECT 333 cid, 30 amt, 'AC' ind FROM dual UNION ALL
SELECT 333 cid, 90 amt, 'AC' ind FROM dual UNION all
SELECT 333 cid, 20 amt, 'AC' ind FROM dual UNION all
)i need to break this down from column to rows which is something i know how to do.
however, the hard part is as follow. as you can see, for one particular cid, you could have
two rows with the same ind value. ex. cid=111 has two rows of ind='s', 333 has two rows with inc='ac'
what i need to do is as follow: lets take the simple scenario first
1. for cid=222 we can see that every rows has a different ind value. in this case, all i want to do is to
display columns to row. the output for 222 should be something like this
cid p_amt s_amt ac_amt
==== ==== ===== ======
222 100 100 20
the only thing here is converting columns to rows.
2. the second step is the complex one. lets take cid=111. if you notice, there are two rows for ind=s
in this case what i want to do is to display this in two rows but the amount will differ.
the output should be something like this
cid p_amt s_amt ac_amt
==== ==== ===== ======
111 142.8 200 20
111 57.14 80 20
what the output above shows is that columns got transform into rows but since there were two or more rows with same ind for a specific cid(ex 111)
i created two rows instead of 1 . also if you notice, the p_amount is not 200 but a percentage amount
i got the value of p_amt with the following formula: s_amount for each row/sum(ind='s') .
ex. (200 / (200+80 - sum of s ind)) * p_amt(ind=P) for the second rows same logic (80/(200+80) )* p_amt (ind=P)
same formula applay for ac amount (200 / (200+80 - sum of s ind)) * c_amt(ind=AC)
3. for cid=333 same logic as per step 2 but 3 ROWS needs to be display since there are 3 rows with ind=ac
in summary, when the ind for a specific cid is unique (no duplicate value, ex cid 222) then convert from columns to rows (1 row per specific cid)
when a particular cid has rows with same ind such as cid 111 and 333, then i want to convert columns to rows but instead of 1 row i want to convert into multiple
row and apply % to p_amt using formula above.
final output should be
cid p_amt s_amt ac_amt
==== ==== ===== ======
222 100 100 20
111 142.8 200 14.28
111 57.14 80 5.72
333 64.26 64.26 30
333 186.84 186.84 90
333 42.85 42.85 20
can some one help write a query for such logic that produce result as above?
i am looking into having a query for this. but all solutions are welcome if it cannot be done in single query
thanksHi Frank, thanks for the query once again. i will run it later with the sample data. but first let me explain what i am trying to do here briefly.
here are answer to your comments and explanation follow
When there is only 1 row with ind='P' for a given cid, it looks like you want 1 row of output for each row where ind='AC', or for each row where ind='S', whichever is greater.
----yes when there is one P i want one row of output for each rows in AC or S only if S or AC has TWO or MORE rows whichever is greater
When there is more than 1 row with ind='P' for a given cid, it looks like you want each of those rows with ind='P' joined to each of the rows you would get otherwise.
--- for every P row same logic as point above applies for each P row. so if there are 1 P and two S we will see two rows. if there are two P and two S then we would see 4 rows
since for every P we need to apply the logic in in first question above
When all the rows for a cid have ind='P', you want them, so the query above has a outer-join between the "table" with the 'P' data and the other "tables". (Most of the "tables" are actually sub-query result sets.)
--- when all rows are P just display the data columns to rows for the same number of P rows. if there are two P, then two rows, if 3 P then 3 rows in row format.
also, if there is no P but you have S and AC. the number of rows display should be whichever is greater and of course the p_amt column will be null since there is no P. so in the case of cid=555, there should be one row for cid=555 with p amt null and s amount populated and c amount populated
so cid = 555 should be
cid p_amt s_amt c_amt
=== ===== ====== =======
555 null 142.86 200
555 null 57.14 80
555 null 142.86 200
555 null 57.14 80In this case there is no P so take AC and apply formulat to S. also the same situation could happen where there is only S rows or only AC rows like cidi=666 and cid=777. these data should be diplay as same logic as cid=444
Below is an explanation
again consider the following data.
WITH table1 AS
SELECT 111 cid, 200 amt, 'P' ind FROM dual UNION ALL
SELECT 111 cid, 200 amt, 'P' ind FROM dual UNION all --added another P
SELECT 111 cid, 200 amt, 'S' ind FROM dual UNION ALL
SELECT 111 cid, 20 amt, 'AC' ind FROM dual UNION ALL
SELECT 111 cid, 80 amt, 'S' ind FROM dual UNION ALL
SELECT 222 cid, 100 amt, 'P' ind FROM dual UNION all
SELECT 222 cid, 80 amt, 'P' ind FROM dual UNION all --added another P
SELECT 222 cid, 100 amt, 'S' ind FROM dual UNION ALL
SELECT 222 cid, 20 amt, 'AC' ind FROM dual UNION ALL
SELECT 333 cid, 300 amt, 'P' ind FROM dual UNION all
SELECT 333 cid, 300 amt, 'S' ind FROM dual UNION ALL
SELECT 333 cid, 30 amt, 'AC' ind FROM dual UNION ALL
SELECT 333 cid, 90 amt, 'AC' ind FROM dual UNION all
SELECT 333 cid, 20 amt, 'AC' ind FROM dual union all
SELECT 444 cid, 900 amt, 'P' ind FROM dual UNION all --added these two
SELECT 444 cid, 1000 amt, 'P' ind FROM dual UNION all
SELECT 555 cid, 200 amt, 'S' ind FROM dual UNION ALL
SELECT 555 cid, 200 amt, 'S' ind FROM dual UNION ALL
SELECT 555 cid, 200 amt, 'AC' ind FROM dual union all
SELECT 555 cid, 80 amt, 'AC' ind FROM dual union all
SELECT 666 cid, 100amt, 'S' ind FROM dual UNION ALL
SELECT 666 cid, 100amt, 'S' ind FROM dual UNION ALL
SELECT 777 cid, 50amt, 'AC' ind FROM dual UNION ALL
SELECT 777 cid, 50amt, 'AC' ind FROM dual UNION ALL
this dataset represents amount. think of P indicator as a loan of $200 for cid=111. think of S as some type of interest. AC is along the same line as S.
one loan (P) could have multiple S and one or no AC.
one loan(P) could have just one row or more rows with P such as cid=444 and no S or AC
one loan P could have multiple AC and so on
each row in the output represent the percentage amount of the Loan base on the interest S or AC.
for example. lets take cid=111 in data above. we can see there are two Ps Two S and 1 AC.
for a particular cid, i want to check if there are one or more S or one or more AC.
in this case there are two S and i should display the data in row format in two rows. if there were 3 S then that would have been 3 rows display for cid=111.
if you look at the output below, you will see first two rows and the value for S remain the same as the data above(200 and 80)
if you look at the p_amt, the amt is NOT the same as the original data. the original data has 200. when you apply the formula mentioned in previous post, p amt gets split into different amount for the two rows and they add up to 200. if there were 3 S in the original data, then you will see 3 rows and the p amt as well as the c_amt will be less
since all need to add up to the original amount in the dataset. this scenario happen when there are two or more S or two or more AC.
the second set of data after the blank line, is the same as the first set. this is because there are two P with same amount, and the same logic should be apply for all the P present.
cid p_amt s_amt c_amt
=====================
111 142.86 200.00 14.29
111 57.14 80.00 5.71
111 142.86 200.00 14.29
111 57.14 80.00 5.71lets take another example, cid=444 only has two P and no S or AC. in this case just display the data in row format. so there should be two rows only, s_amt and c_amt should be null since there is none.
another example is cid=222, there are two P, one S and one AC. since there is not two or more S or AC, then we need to convert all rows from columns to rows and display one rows. however, we can see that there is two P, so for the second P same logic apply. this is why you see duplicate rows because we need to apply same logic for every P row even though data might look the same.
222 100.00 100.00 20.00
222 80.00 100.00 20.00if there was only one P for cid=200 then we would have seen this output
222 100.00 100.00 20.00so in summary, we are converting from columns to rows for each set of cid and depending on the number of S rows or AC rows, that is how many rows should be display for a specific cid. then like in the case of cid=111, p_amt and c_amt in all rows should added up to the original amount. this is done by the RATION function that determine the percentage to apply base on the formula provided.
same with cid=333. in this case there are 3 AC so 3 rows should show and the p_amt and s_amt should be derive base on the percentage and add up to original value.
as i mentioned, there could be multiple P and they might have different amount, the same logic should apply for every P row therefore you could see duplication of rows such as output for cid=111
i know this is long but i hope this helps. feel free to ask any other questions and thanks for your help. i will try the query. if you feel you need to add something else to the query base on explanation above, feel free and let me know.
Edited by: elmasduro on Feb 16, 2011 7:07 AM
Edited by: elmasduro on Feb 16, 2011 7:14 AM
Edited by: elmasduro on Feb 16, 2011 7:42 AM
Edited by: elmasduro on Feb 16, 2011 8:48 AM
Edited by: elmasduro on Feb 16, 2011 10:37 AM -
Generating rows from single column
hi All,
I need u guys help for following issue.
Supose i have a table called parameters with following columns
TABLE - PARAMETERS;
desc PARAMETERS;
customer_id number(9)
params varchar2(3500)
say againt a customer id 100 data stored in params like below
X;Y;PP;CH;KK;RX:KY
My question is ..is it possible to have a SQL query that can split into multiple rows like below.
100 X
100 Y
100 PP
100 CH
100 KK
100 RX
100 KY
Basically i am looking for a solution with a general sql query with out writing plsql.
ThanksI had the following in an old code archive which does what you want - assuming the semi-colon is the separator.... (hope the code tags format this correctly!)
with tmp as (
SELECT 100 as customer_id, 'X;Y;PP;CH;KK;RX;KY' as params FROM DUAL
UNION ALL
SELECT 200 as customer_id, 'UI;RT;QE' as params FROM DUAL
select t1.*,
trim(replace(substr(t1.params,mstart,(t2.mlevel-mstart)+1),';','')) as data_split
from tmp t1
join (
select customer_id,substr(params,level,1) as mchar,
level as mlevel,nvl(lag(level) over (partition by customer_id order by level),0)+1 as mstart
from tmp
where substr(params,level,1)=';'
or level=length(params)
connect by level<=length(params)
and prior customer_id=customer_id
AND PRIOR DBMS_RANDOM.STRING ('p', 10) IS NOT NULL
) t2
on t1.customer_id=t2.customer_id -
Generate columns and rows with a loop
$query = "SELECT * FROM `Sale` WHERE `Date` >= '2007-01-11' AND `Date` <= '2007-01-14' GROUP BY `Date` ORDER BY Date ASC";
$result = mysql_query($query);
How to generate columns and rows with the above mysql query to get this output:
Name/Day 11 12 13 14
Appple 30 25 26 28
Orange 5 23 12 0
Grape 7 16 0 10
The header I managed to create but not the rows. This is what I did.
<?php
$query = "SELECT * FROM `Sale` WHERE `Date` >= '2007-01-11' AND `Date` <= '2007-01-14' GROUP BY `Date` ORDER BY Date ASC";
$result = mysql_query($query);
//Header
?>
<tr>
<td valign=top>
<table cols=6 width=100% border="1" cellspacing=1 cellpadding=1>
<th BGCOLOR=#6C83B0 height="25" width="1"><font color=#FFFFFF size='1'><b></th>
<th BGCOLOR=#6C83B0 width="120" align="left"><font color=#FFFFFF size='2'><b>Name/Day</b></th>
<?
$result = mysql_query($query);
if ($daterow = mysql_fetch_array($result)) {
do {
$TimeStamp = strtotime("$daterow[Date]");
$day = date("j", $TimeStamp);
?>
<th BGCOLOR=#6C83B0 width="5" align="center"><font color=#FFFFFF size='2'><b><?echo $day?></b></th
<?
}while ($daterow = mysql_fetch_array($result));
?>
<th BGCOLOR=#6C83B0 width="5" align="center"><font color=#FFFFFF size='2'><b>Total</b></th>
<th BGCOLOR=#6C83B0><font color=#FFFFFF size='2'><b></b></th>
<th BGCOLOR=#6C83B0 width="1"><font color=#FFFFFF size='1'><b></b></th>
</tr>
<?
//Rows
$result = mysql_query($query);
if ($row = mysql_fetch_array($result)) {
do {
include("../lib/browser_sales_daily.php");
} while ($row = mysql_fetch_array($result));
?>
</tbody></table>
<?php
//browser_sales_daily.php
print <<<EOD
<td BGCOLOR=#EDEDED align="left">
<font size="2">$row[Name]</font>
</td>
EOD;
// <<<< HOW TO GENERATE ROWS HERE WITH A LOOP????? >>>
print <<<EOD
</tr>
EOD;
?>Make sure the photos are "within" celsl and they should sort along with the rest of your data. One way to do this: select a photo that you have in the sheet that is not sorting with the data, command-x to cut, click once in a cell, and paste. Then adjust the row height and width to make the images larger.
SG -
Generating multiple rows through select result
Hi,
I have the requirement to generate rows based on the return of my select.
This is the source of my table mytab
COL1 CO2
ROWS 5
f01 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f02 ^[0-9]{1,}$Now I need this output.
ITEM REGEXPR
f01_0001 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f01_0002 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f01_0003 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f01_0004 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f01_0005 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f02_0001 ^[0-9]{1,}$
f02_0002 ^[0-9]{1,}$
f02_0003 ^[0-9]{1,}$
f02_0004 ^[0-9]{1,}$
f02_0005 ^[0-9]{1,}$The value of Rows in my example "5" can be dynamically (could be 50 as well).
The rows for f01 and f02 could also be 10
So the source of my table could also look like this:
COL1 CO2
ROWS 50
f01 ^[a-zA-Z0-9ÖÄÜüöäß%_ .,:;!?&[:space:]\(\)-]+$
f02 ^[0-9]{1,}$
f03 ^[0-9]{1,}$
f04 ^[0-9]{1,}$
f05 ^[0-9]{1,}$
f06 ^[0-9]{1,}$
f07 ^[0-9]{1,}$
f08 ^[a-z]{1,}$
f09 ^[a-z]{1,}$
f10 ^[a-z]{1,}$Hope for help.
Best regards,
TobiasHi,
The usual way to do that is to join your table to a Counter Table , a table (or, as in the example below, a sub-query result set) that counts 1, 2, 3, ... as high as you need to go.
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 50 -- max value needed (or higher)
SELECT m.col1 || '_'
|| TO_CHAR (c.n, 'FM0000') AS item
, m.col2 AS regexpr
FROM mytab m
JOIN cntr c ON c.n <= 5 -- or some expression from m
ORDER BY item
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using.
See the forum FAQ {message:id=9360002}
Edited by: Frank Kulash on Jul 5, 2012 7:32 AM -
Problem while creating a new row
I am trying to create a new row in FulfillmentLineEntryResultVORowImpl which will be within the CheckAvailabilityOutputVORowImpl.
For that I am trying to do the following coding and I am getting the "NullPointerException" while creating the "flrow".
Please look in the code and suggest me the correct way.
CheckAvailabilityOutputVOImpl outputVO = getCheckAvailabilityOutput1();
CheckAvailabilityOutputVORowImpl outputRow = null;
outputRow = (CheckAvailabilityOutputVORowImpl)outputVO.createRow();
FulfillmentLineEntryResultVOImpl fle = getFulfillmentLineEntryResult1();
FulfillmentLineEntryResultVORowImpl flrow = (FulfillmentLineEntryResultVORowImpl)fle.createRow();
flrow.setErrorCode("26");
fle.insertRowAtRangeIndex(0, flrow);
and
public CheckAvailabilityOutputVOImpl getCheckAvailabilityOutput1() {
return (CheckAvailabilityOutputVOImpl)findViewObject("CheckAvailabilityOutput1");
public FulfillmentLineEntryResultVOImpl getFulfillmentLineEntryResult1() {
return (FulfillmentLineEntryResultVOImpl)findViewObject("FulfillmentLineEntryResult1");
}Hi,
I am using transient VO.
The code that i mentioned earlier is to create the dummy response for the web service in error condition.
For normal condition we are getting data from XML and by using readXML I am generating row nicely.
The piece of code for normal scenario where it is working nicely is...
Document doc = sendMessage("CheckAvailabilityInput", headerNode);
CheckAvailabilityOutputVOImpl outputVO = getCheckAvailabilityOutput1();
outputVO.readXML(doc.getDocumentElement(), -1, getXslForReadXML());
if (AppsLogger.isEnabled(AppsLogger.FINE)) {
Node headerNode1 = (XMLNode)outputVO.writeXML(-1, XMLInterface.XML_OPT_ALL_ROWS | XMLInterface.XML_OPT_ASSOC_CONSISTENT);
try {
Writer sw = new StringWriter();
((XMLNode)headerNode1).print(sw);
} catch (IOException e) {
AppsLogger.write(this.getClass(),
"Couldn't convert the VO to xml",
AppsLogger.FINE);
outputRow = (CheckAvailabilityOutputVORowImpl)outputVO.getRowAtRangeIndex(0);
And The xml that I am using is like below....
<?xml version="1.0" encoding="utf-8"?>
<checkAvailabilityOutput xmlns:op="http://xmlns.oracle.com/apps/scm/orderPromising/orderPromising/promisingServices/types/">
<PromisingSystem>DOO-OP</PromisingSystem>
<PromisingInstance>Instance</PromisingInstance>
<PromiseDate>2012-08-22</PromiseDate>
<FulfillmentLineEntryResult>
<FulfillmentLineReply>
<FulfillmentLineIdentifier>FID-003</FulfillmentLineIdentifier>
<NumberOfAltOptions>0</NumberOfAltOptions>
<DefaultAvailabilityOption>
<OptionRank>0</OptionRank>
<OptionSummary>0</OptionSummary>
<FulfillmentLineResult>
<FulfillmentLineIdentifier>FID-003</FulfillmentLineIdentifier>
<TotalPrice>8000</TotalPrice>
<TotalProfit>-392000</TotalProfit>
<TotalMargin>-98</TotalMargin>
<TotalValue>-392000</TotalValue>
<NumberOfSplits>0</NumberOfSplits>
<NumberOfSubstitutions>0</NumberOfSubstitutions>
<FillRate>100</FillRate>
<NumberOfAtpItems>1</NumberOfAtpItems>
<NumberOfCtpItems>0</NumberOfCtpItems>
<SourcingRule></SourcingRule>
<ResultDetail>
<SplitLineIdentifier></SplitLineIdentifier>
<Customer>CUST_ID_001</Customer>
<CustomerSite>CUST_SITE_001</CustomerSite>
<InternalSalesOrderDestOrg>
<OrgId></OrgId>
</InternalSalesOrderDestOrg>
<PromisingStatus></PromisingStatus>
<RequestedDate>2012-06-02</RequestedDate>
<PromisingType>Ship</PromisingType>
<ExpectedArrivalDate>2012-06-01</ExpectedArrivalDate>
<ExpectedShipDate>2012-06-01</ExpectedShipDate>
<ExpectedPickDate>2012-06-01</ExpectedPickDate>
<RequestedItem>ITEM_CODE_001</RequestedItem>
<ExpectedAvailableItem>ITEM_CODE_001</ExpectedAvailableItem>
<ExpectedAvailabilityOnRequestedDate>0</ExpectedAvailabilityOnRequestedDate>
<ExpectedAvailableQuantity>200</ExpectedAvailableQuantity>
<ExpectedAvailableQuantityUOM>EA</ExpectedAvailableQuantityUOM>
<ExpectedShipFromOrg>
<InstanceId></InstanceId>
<OrgId>HYDERABAD</OrgId>
</ExpectedShipFromOrg>
<ExpectedDropShipSupplier></ExpectedDropShipSupplier>
<ExpectedDropShipSupplierSite></ExpectedDropShipSupplierSite>
<ExpectedMode></ExpectedMode>
<ExpectedService></ExpectedService>
<ExpectedCarrier></ExpectedCarrier>
<CarrierCalendar></CarrierCalendar>
<ExpectedDemandClass></ExpectedDemandClass>
<ExpectedTotalFulfilmentCost>400000</ExpectedTotalFulfilmentCost>
<ExpectedShippingCost>0</ExpectedShippingCost>
<ExpectedMargin>-98</ExpectedMargin>
<Price>8000</Price>
<Profit>-392000</Profit>
<Value>-392000</Value>
<LineFillRate>100</LineFillRate>
<ErrorCode></ErrorCode>
<ErrorMessage></ErrorMessage>
<PeggingDetail>
<ItemId>ITEM_CODE_001</ItemId>
<OrgInfo>
<InstanceId></InstanceId>
<OrgId>HYDERABAD</OrgId>
</OrgInfo>
<ShippingCalendar>Calendar1</ShippingCalendar>
<ReceivingCalendar>Calendar2</ReceivingCalendar>
<ManufacturingCalendar>Calendar3</ManufacturingCalendar>
<ATPDetail>
<Quantity>200</Quantity>
<QuantityUom>EA</QuantityUom>
<ATPCost>400000</ATPCost>
<ATPMode>3</ATPMode>
<LeadTime>0</LeadTime>
<RequiredQuantity>200</RequiredQuantity>
<RequiredDate>2012-06-01</RequiredDate>
<AllocationRule></AllocationRule>
<DemandClass></DemandClass>
</ATPDetail>
</PeggingDetail>
</ResultDetail>
</FulfillmentLineResult>
</DefaultAvailabilityOption>
</FulfillmentLineReply>
</FulfillmentLineEntryResult>
</checkAvailabilityOutput> -
Generating sequence numbers not stored in the database
how to generate row numbers in the select statement
I need my query to return row numbers as a column which need to be displayed in the front end reporting tool.
should return something like this..
RANK NO DEPTID DEPT_NAME
1 10 SCOTT
2 10 JAMES
3 20 PETERSomething like
SELECT row_number() over (order by deptid) rank_no, deptid, dept_name
FROM deptJustin -
Filter not being generated into where clause
Hi,
I have a simple mapping that has a source table, a filter, and a target table that is set to DELETE. The source table has many rows, but the filter would narrow down these rows by a lot. When I generate the code, the cursor that gets created SELECTs the whole table then there is an IF statement that is applied to each row with the filter condition. A lot less processing would be required if the filter was implemented as a WHERE clause in the cursor, but I can't get it to generate this way. I realize that deletes automatically generate row-based code but it would still be row-based if the WHERE clause was in the cursor.
Is there any way to get it to generate the filter as a WHERE clause in the cursor?Hi,
In general, Warehouse Builder gives you a number of different operating modes:
- set-based: which does everything in (one) SQL statement. This method is most performant, but has some limitations. Warehouse Builder today does not support set-based deletes (arguably, deletes are not the most common operation in a data warehouse).
- row-based: which is optimal for debugging. In row-based mode, you get as many records as possible and all operations/transformations take place in PL/SQL. This option gives you most debugging capabilities.
- row-based bulk: which is the previous method fetching rows in bulk (e.g. 100 by 100). Bulk processing speeds up the overall processing.
- row-based target only: in this mode we push as many of the operations/transformations as possible into the query (cursor). I.e. your filter (in your case) would be implemented as a restriction on the filter.
- row-based target only in bulk: see previous.
Warehouse Builder's default operation is set-based fail over to row-based. I.e. because we do not support set-based delete statements, I suspect you fall back to the row-based method of execution, which is not ideal in your case. I suggest you use the row-based target only option in order to get optimal performance for your scenario.
Note that for the deletes that are common in DW scenarios the row-based bulk deletes that we generate are often faster than set-based deletes. Also note that if you perform a complete delete (or even truncate) followed by an insert that Warehouse Builder does issue one statement for emptying the table.
Thanks,
Mark.
Maybe you are looking for
-
Windows ODBC Client for Timesten in Solaris Sparc
Hello, i need help to solve this issue : I have a Timesten version 5.1.28 ( 32 bits) running in Solaris Sparc and a Windows 2003 server connected to the same network. I need to install a Timesten ODBC client in my windows 2003 server in order to get
-
Sir, plz send me the full customisation and end user manual for Co module my email id is [email protected] I will give the point also after getting the data thanks bye
-
Section 6 Use Restrictions When using the Service you must comply with the terms of this contract, the terms of the Microsoft Windows Azure Marketplace Service Agreement, all applicable laws, and the Microsoft Anti-Spam Policy . You must also obey an
-
I have been having a problem with my music in iTunes. It seems that whenever my computer defragments, some songs become unplayable. The file is still in iTunes and in the itunes music folder, but it's size is 0 bytes. I don't know if it is from the d
-
When attempting to perform updates on my iphone, it asks for credit card information. I give them the information directly from the card but then it tells me that the security code is invalid. I have rechecked the information several times which also