Looping through several records where some share a primary key.
Can anyone help me write this code... (fix as is, or restructure). I'm trying to perform methods on various objects which share a primary key (as I iterate through them), then a final method when the last matching primary key is met (they are present in grouped order), however I'm stuck at the new primary key when I want to use the old grouping (grouping code not shown).
Sring primaryKey = "P1";
for (MyRecord x : myArrayList) {
while (s.getPKey() == primaryKey) {
// perform operations ... add results to array list 'y'
} else {
primaryKey = s.getPKey();
// Here's the kicker: PERFORM METHOD ON OBJECTS FROM PREVIOUS LOOP --
performMethod(NOT ON THIS array list Y-- LAST array list Y)
}EXAMPLE:
P1
P1
P1
P1
P2
P2
P3
P3
P3
P3
P4
present in grouped order), however I'm stuck at the new primary key when I want to use the old grouping (grouping code not shown).1. Normally a primary key means just 1 object associated with that key
2. See the line above. You have posted code, then you say "this code is a problem. Code I haven't shown you is my problem" How are we supposed to help you?
Similar Messages
-
Hi everyone
I am new in crystal reporting and using Crystal Reports XI release 2. Firstly I should explain what I need to have. In my database I have got a parent table called Initiatives and a child table called benefits. One initiative has got many benefits associated with it and benefits are updated regularly by the users. Now my manager wants me to create an Initiative reports in such a way that all the initiatives are displayed and against each initiative there should be a box filled with either of these colour (red, yellow, green).
Let's say if Initiative "X" has got 10 benefits and if one or more benefits are outstanding by more than 2% then the colour of the box should be red. And if no benefit is outstanding by more than 2% and one or more benefits are outstanding more then 1% and less then 2% then colour of box should be yellow. And if no benefit is outstanding more than 1% then colour of box should be green.
Now for this I have created a report displaying all initiatives and a sub report with a SQL command containing the data from the benefits table. I have also included a database field which I would use as a box.
Now I want to loop through each record of the crystal report till the last record and format the field as per condition. I would probably use nested loop to look for the status of the benefits but I don't know how to do this in CR. In short I am looking to do this thing in CR
While Recordset.EOF
Do
But I can't find a key word for EOF or count-1 or some thing like that.
Seeking the help of you guys.
Regards,It would be much easier to simply let Crystal's conditional formatting do this for you.
Almost every formatting aspect of each object in Crystal can be controlled via expressions. Just click on the expression button to the right of the property...
ido -
Custom pll to disable form messages while looping through block records
I need to loop through block records in CUSTOM pll to check for if one check box is checked or not. But in that process the messages written at the forn level are popping up which are of no use to the user. I want to disable the messages for my looping. I would enable it after the processing in CUSTOM PLL
Regards,
SSHello,
Here is the Forms forum, and you would increase chances to get an answer by posting in the EBS forum.
Francois -
How to Alter any table to make some fields Composite Primary Key
I need to Alter Table to make some fields Composite Primary Key.
Is it possible to do this ?
Please give any example.
Regards,
AgrawalVAgrawal
If you are looking for an example to create a composite primary key, here you are.
sql> Alter Table myTable add constraint pk_myTable primary key(col1, col2, ...coln) ;
where
pk_myTable is the name of the primary key constraint,
myTable is the name of the table that you want to create a constraint on and
col1...coln are the column names in the table <myTable) -
Overwriting a record with part of same primary key
Hello Everyone,
Could anyone please give a suggestion about how to overwrite the record with part of same primary key?
I have 5 key fields.
A1
A2
A3
A4
A5
I have to overwrite the record if A5 changes with same A1 A2 A3 A4.
I cannot take off A5 as part of primary key. If I use modify or insert, its creating a new record with the new A5. But I am still having the old record in the table (with old A5), which I don't want it to be there.
Thank you,
Rushihi,
That's right.
u have to delete record from database table .....
then u can add a new record...
use delete <database_table> from table <internal_table> -
Looping through several employee numbers
My program calculates salary for a given period for an employer and prints the result in a word doc using the function MS_WORD_OLE_FORMLETTER. This works fine when I have only one employer. When I enter several employee numbers the information is collected correctly in a table but only the first record is printed. I have an impression that the program executes as many times as there are employee numbers instead of executing once by looping through the employee numbers before printing the result. How can I print all the information for several employers?
The shorter version of the code is as foolows:
Loop at i_result into w_rt "loop through payroll results for given period
case w_rt-lgart
"do some calulations for this employee for
FIELD-SYMBOLS: <fsd>, <fsl> type any.
CONCATENATE 'MF' w_rt-lgart INTO keyA_Merge.
assign component keya_merge of structure T_MergeData to <fsd>.
if sy-subrc = 0.
<fsd> = <fsd> + w_rt-betrg.
endif.
end case
endloop
append t_mergedata to Fdata
"Now create mail merge for all employees using Fdata
call function 'MS_WORD_OLE_FORMLETTER'
exporting
WORD_DOCUMENT = FILEFORM
HIDDEN = 0
WORD_PASSWORD =
PASSWORD_OPTION = 1
FILE_NAME = FILEDATA
NEW_DOCUMENT =
DOWNLOAD_PATH = FILEPATH
PRINT = PFPRINT
tables
DATA_TAB = FDATA
FIELDNAMES = pFIELDS
My problem is that the loop executes for one Employee and then goes on to the end of the program to do the mail merge. the program then "restarts" for the necxt employee. However through each program run/cylce the table t_mergedata is appended with the correct information. I would like to first collect all this info before executing the FM for all the records in t_mergedata. -
How to loop through xml records from file without ROW , /ROW tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
-
Script code sample for looping through the records from xml data file in formCalc script
Hi
I have a xml data file which contains a sequence of repeating applicant data like given below
US
II
CEO
Mr
111111111
0000000111
GuarantorA
111
IN
11111
WILLIAMS1
R3
KENNETH1
City1GU
PA
1934-03-14
[email protected]
GU
R
113 Lazlo LaneCA
Suite 3500CA
OaklandCA
TX
11345
AL
I want to assign a textfield with a value based on the value of coap_flag.
So i need to loop through all the record and check the value of coap_flag and then assign the textfield a value based on that.
I am new to Adobe livecycle...Please help me how it can be done.
I have developed something like this
foreach Item in ($record.applicant[*].coap_flag) do
test.value=Item
if(test.value=="MA")then
concat($record.applicant.first_name,$record.applicant.middle_name)endif
endforUsing the data you posted in the forum, I copied it a couple of times to give multiple records and used this code to extract the different values that you wanted. I had to wrap it in a <root> node that I called root (to make it valid XML). In my case I wrote the extracted values to a field, but in your case you can do whatever you want with them. Note that this was done in javascript:<br /><br />var currentElement;<br />var obj;<br /><br />//Get the nodes below the root node in the dataDom<br />obj = xfa.datasets.data.root.nodes;<br /><br />//Set an initial value for the textField<br />TextField1.rawValue = "The values of the coap_flag are: ";<br /><br />//Loop through the nodes in the obj set <br />for (i=0; i< obj.length ; i++){<br /> //set the currentElement to the 1st child node<br /> currentElement = obj.item(i);<br /> //Check to see if it is an applicant node<br /> if (currentElement.name == "applicant"){<br /> //It is an applican, now find the coap_flag node value and write it to the text field<br /> TextField1.rawValue += "\n" + xfa.resolveNode("xfa.datasets.data.root.applicant[" + i + "]").coap_flag.value;<br /> }<br />}
-
Loop through the records from xml data file in formCalc script
Hi
I have a xml data file which contains a sequence of repeating applicant data like given below
US
II
CEO
Mr
111111111
0000000111
GuarantorA
111
IN
11111
WILLIAMS1
R3
KENNETH1
City1GU
PA
1934-03-14
[email protected]
GU
R
113 Lazlo LaneCA
Suite 3500CA
OaklandCA
TX
11345
AL
I want to assign a textfield with a value based on the value of coap_flag.
So i need to loop through all the record and check the value of coap_flag and then assign the textfield a value based on that.
I am new to Adobe livecycle...Please help me how it can be done.
I have developed something like this
foreach Item in ($record.applicant[*].coap_flag) do
test.value=Item
if(test.value=="MA")then
concat($record.applicant.first_name,$record.applicant.middle_name)endif
endforUsing the data you posted in the forum, I copied it a couple of times to give multiple records and used this code to extract the different values that you wanted. I had to wrap it in a <root> node that I called root (to make it valid XML). In my case I wrote the extracted values to a field, but in your case you can do whatever you want with them. Note that this was done in javascript:<br /><br />var currentElement;<br />var obj;<br /><br />//Get the nodes below the root node in the dataDom<br />obj = xfa.datasets.data.root.nodes;<br /><br />//Set an initial value for the textField<br />TextField1.rawValue = "The values of the coap_flag are: ";<br /><br />//Loop through the nodes in the obj set <br />for (i=0; i< obj.length ; i++){<br /> //set the currentElement to the 1st child node<br /> currentElement = obj.item(i);<br /> //Check to see if it is an applicant node<br /> if (currentElement.name == "applicant"){<br /> //It is an applican, now find the coap_flag node value and write it to the text field<br /> TextField1.rawValue += "\n" + xfa.resolveNode("xfa.datasets.data.root.applicant[" + i + "]").coap_flag.value;<br /> }<br />}
-
I was wondering how I can loop through all records in a database?
I'm using a do while loop to loop through all the records in a database is there a way I can simulate to EOF. I tried something to simulate it but I don't think it'll work. I assume there's a better way.
Here's my code:
boolean noRecords=false;
do
noRecords=false;
if (queryResults.next())
serverOutput.print(queryResults.getInt("itemID");
serverOutput.println(queryResults.getString("itemName");
else
noRecords=true;
}while(noRecords==false);i think i know what you mean...
try this
while (queryResults.next()) {
serverOutput.print(queryResults.getInt("itemID");
serverOutput.println(queryResults.getString("itemName");
when .next() returns false, it will exit the while loop. you don't need the other code you have there, the above should do it all.
is that what you're after? -
How to loop through xml records and repeatedly display
I have 1 table in my rtf and the table typically reflects 1 row (grouping) from my xml data, however there are some instances where i need to take 1 row from my xml data and display the table multiple times.
i.e.
xmldata:
item TOTAL_QTY CONTAINER_QTY
x 500 250
I need to take that row and display the table in my rtf two times. I tried to encapsulate my table in a <?for-each:xdoxslt:foreach_number($_XDOCTX,0,TOTAL_QTY,CONTAINER_QTY)?> loop looping/re-displaying the table until a reach TOTAL_QTY, but once I'm in this loop it's like i dont have access to the actual xml data fields. How can I achieve this effect?1. Please tell us your first name and put it in your handle and/or profile to help us.
2. Explain your question in more detail, perhaps with an example and by showing code you already are using.
Scott -
How to loop through report records and update the record
I have a updateable report. And there is a select LOV in that report. How to loop though the report and save all the changes to the LOV.
1. Please tell us your first name and put it in your handle and/or profile to help us.
2. Explain your question in more detail, perhaps with an example and by showing code you already are using.
Scott -
Looping through records in XML Variable !!
Hi,
I am getting no way how to do this. I am getting the below XML from a custom DSC component. Now I need to process it.
<root>
<records total_records="4">
<record>
<jobno>1122</jobno>
<cust_name>Abhinav</cust_name>
<email>[email protected]</email>
<stat>1</stat>
</record>
<record>
<jobno>2233</jobno>
<cust_name>Doctor Dhober</cust_name>
<email>[email protected]</email>
<stat>0</stat>
</record>
<record>
<jobno>4666</jobno>
<cust_name>Vinau Dubey</cust_name>
<email>[email protected]</email>
<stat>1</stat>
</record>
<record>
<jobno>7677</jobno>
<cust_name>Nelesh Poda</cust_name>
<email>[email protected]</email>
<stat>0</stat>
</record>
</records>
</root>
Now I need to loop through every record & do some stuff for each one. In my process I have to send a mail to each of the user in the XML file. I tried it using SET VALUE's Node Set Functions, but not successful. Any help.
Thanks.
AbhinavYour xpath doesn't match your XML - you are missing the root node in your xpath expression:
Expression: /process_data/myXML/records/record[1]/email
should be:
/process_data/myXML/root/records/record[1]/email
When you build your loop there is one other thing to be careful of. If you evaluate an xpath variable inside of another xpath expression, it gets inserted as a string. This happens even if the variable is an integer. For example: If I have an integer variable counter which is set to 3 and evaluate:
/process_data/myXML/root/records/record[/process_data/@counter]/email The xpath expression will insert "3" (a string) and not an integer as you would expect. The result will not be the third node. This can be a source of frustration and its hard to debug.
Instead, use the number function inside the expression:
/process_data/myXML/root/records/record[number(/process_data/@counter)]/email
I've attached a sample process that shows this. -
How do i loop through a pl/sql collection based on a condition.
hi, can any one help me or provide me sample code where i have to loop through a collection based on condition . just like where clause in sql. your help is highly appreciated....
{code}
create table MODEL1
model_id NUMBER ,
model_seq NUMBER,
p_ind VARCHAR2(1)
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (4, 103, 'U');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (3, 102, 'P');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (2, 101, 'U');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (1, 100, 'P');
MODEL PROCEDURE......
procedure ( param1,param2) ( assume this procedure is being called from other procedure and collection has been populated already)
TYPE l_tab is table of MODEL1%rowtype;
begin
loop through l_tab records where ltab.model_id=param1 and p_ind =p
Join based on if else condition.
if param2 is not null then
l_tab.model_seq=param2 and ltab.p_ind='P'
if param2 is null then
l_tab.p_ind='P' etc...........
{code}Hi,
Try something like this:
DECLARE
TYPE L_TAB IS TABLE OF MODEL1%rowtype;
TAB L_TAB;
param1 number := 1;
param2 number := 999;
BEGIN
select
model_id
,model_seq
,p_ind
bulk collect into TAB
from
MODEL1
DBMS_OUTPUT.PUT_LINE('PARAM1: ' || PARAM1);
DBMS_OUTPUT.PUT_LINE('PARAM2: ' || PARAM2);
DBMS_OUTPUT.PUT_LINE(' MODEL_ID, MODEL_SEQ, P_IND' );
FOR X IN TAB.FIRST .. TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OLD: ' || TAB(X).MODEL_ID || ' ' || TAB(X).MODEL_SEQ || ' ' || TAB(X).P_IND );
IF TAB(X).model_id = param1 AND TAB(X).p_ind = 'P' THEN
IF param2 IS NOT NULL THEN
TAB(X).model_seq := param2;
-- TAB(X).p_ind := 'P'; -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
NULL;
END IF;
IF param2 IS NULL THEN
-- TAB(X).p_ind := 'P'; -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
NULL;
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE('NEW: ' || TAB(X).MODEL_ID || ' ' || TAB(X).MODEL_SEQ || ' ' || TAB(X).P_IND );
END LOOP;
END;
PARAM1: 1
PARAM2: 999
MODEL_ID, MODEL_SEQ, P_IND
OLD: 4 103 U
NEW: 4 103 U
OLD: 3 102 P
NEW: 3 102 P
OLD: 2 101 U
NEW: 2 101 U
OLD: 1 100 P
NEW: 1 999 P
Regards,
Peter -
How to loop through a collection of records which is return value of func.
Hi all.
Have this situation:
- Stored function (member of pkg procedure) that returns a collection of records.
Package Spec:
=========
type tipo_pvt is table of s08_plan_venta_totalizado_r % rowtype;
rc_pvt tipo_pvt;
(s08_plan_venta_totalizado_r is a view).
Package Body:
=========
select col1
,col2
,etc
bulk collect into rc_pvt
from s08_lista_precio_producto_r lpp
,s03_producto_r prd
where condition;
return rc_pvt;
Once collection is loaded and returned (i know it loads records). I just want to loop through every record on a pl/sql procedure on the client (forms6i procedure), but it gives me the error: ORA-06531 Reference to uninitialized collection:
On the forms6i client procedure i have something like:
procedure p_carga_plan_venta_inv (p_id_plan_venta in number) is
v_contador integer;
v_mensaje varchar2(10);
rc_pvt sk08_gestiona_plan_venta.tipo_pvt; (sk08_gestiona_plan_venta is package name)
begin
rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
-- previous statement dos not fail BUT THIS:
message('rc_pvt.count= '||rc_pvt.count);pause;
DOES FAIL
end;
So my question is : since i have already returned the collection, how come is not initialized....?
Do i have to extend it first? In this case i have to return the number of records in the collection.....
Look what happen when done from sqlplus:
declare
rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
begin
rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
rc_pvt :=
sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
,null
,'m'
,'BS.F'
,to_date('28/02/2001','dd/mm/yyyy'));
end;
SQL> /
Registros en la coleccion =6
Procedimiento PL/SQL finalizado con éxito.
SQL>
I put a dbms_output.put_line on stored function .....
Please help ....!
Apparently it fails when calling the stored function:
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
I don't undestand since this function return the appropiate type. It seems the collection is empty, although having test that on sqlplus works ...
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
function f_genera_plan_venta_inv (p_id_lista_precio in number
,p_id_sucursal in number
,p_tipo_nivel_inv in varchar2
,p_co_unidad_monetaria in varchar2
,p_fe_fin_periodo in date) return tipo_pvt;
for some reason it works on plus:
SQL> declare
2 rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
3 begin
4 rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
5 rc_pvt :=
6 sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
7 ,null
8 ,'m'
9 ,'BS.F'
10 ,to_date('28/02/2001','dd/mm/yyyy'));
11 --
12 dbms_output.put_line('Registros en la coleccion = '||rc_pvt.count);
13 for i in 1 .. rc_pvt.count loop
14 --
15 dbms_output.put_line('En '||i||rc_pvt(i).prd_co_producto);
16 end loop;
17 end;
18 /
Registros en la coleccion =6
Registros en la coleccion = 6
En 1PT.REF.PET.KO05
En 2PT.REF.PET.LM15
En 3PT.ALM.VDR.001
En 4PT.REF.GRN.CN
En 5PT.REF.GRN.KO
En 6PT.REF.GRN.LM
Procedimiento PL/SQL finalizado con éxito.
Don't understand why it works on plus8 (same version that comes with 6i).
Can't loop through records on forms...? WHY ...?
Edited by: myluism on 02-abr-2012 14:40Forms 6i is an antique ... write your code to run on the server.
Multiple examples of how to loop through an array loaded with bulk collect can be found here.
http://www.morganslibrary.org/reference/array_processing.html
The main library page is:
http://www.morganslibrary.org/library.html
Maybe you are looking for
-
Wi-fi worked fine before I upgraded and always connected automatically but now nothing seems to work. Does anyone know how to fix this?
-
Why is the "microphone" missing on my iPhone in Mail?
Just today I noticed that the little microphone is missing from the Mail keyboard when sending Mail. Why?
-
IPAD MINI TOUCH SCREEN NOT WORKING
Ipad mini touchscreen stopped working. Help?
-
How to change order of report painter columns
I have a report which shows the columns in one order when in design mode in GRR2 but when the report runs, the columns display in a different order. When in design mode, you can see the actual output order by clicking the form overview button and se
-
Error 15401: Windows NT user or group not found. Check the name again
when adding a windows login on SQL SERVER 2008 R2 below error is throwing Windows NT user or group 'domain\user' not found. Check the name again. I have gone through the link http://support.microsoft.com/kb/324321/en-us & http://support.microsoft.com