Looping in EJB collection
Hi,
I am developing a Web application that uses Entity beans to access data
in Oracle and DB2.
In that application, everything is done on serversite via JSPs, Servlets
and EJBs (no applet or client application).
I have made different tests optimizing performances using isModified,
maxBeans in cach etc ...
I have observed that finder methods don't take too much time. What
consumes a lot is the loop in the collection of remote interface
returned by finders. I am convinced that the bottelneck is not the EJB
itself but the communication between the caller and the container
(stubs, skelettons, ....). In effect, even when EJBs are in the cach,
the loop is slow.
When we are in a server process like a JSP, a Servlet or a Session bean
running it the same application server than EEJBs, is there a way to
avoid communication via stubs/skelettons and access directly the EJBs ?
Thanks for your help.
Hi,
Yes, I am sure.
In fact, we access a read-only db2 NT database that is a replication of
a mainframe db2 database. To avoid ejbLoad repeated calls, we have used
isModified() technic.
Now that I have good performances (I should say "acceptable"), my
problem is that I should like to, periodically, obliged a reload of the
bean (even if isModified flag returns false) because the database
replication can have changed some data that are in the cash.
Has someone an idea ?
Thanks to everybody,
Manuel
Cameron Purdy wrote:
>
Are you certain that the problem isn't in the repeated calls to ejbLoad?
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"Manuel Rodriguez" <[email protected]> wrote in message
news:[email protected]..
Hi,
I am developing a Web application that uses Entity beans to access data
in Oracle and DB2.
In that application, everything is done on serversite via JSPs, Servlets
and EJBs (no applet or client application).
I have made different tests optimizing performances using isModified,
maxBeans in cach etc ...
I have observed that finder methods don't take too much time. What
consumes a lot is the loop in the collection of remote interface
returned by finders. I am convinced that the bottelneck is not the EJB
itself but the communication between the caller and the container
(stubs, skelettons, ....). In effect, even when EJBs are in the cach,
the loop is slow.
When we are in a server process like a JSP, a Servlet or a Session bean
running it the same application server than EEJBs, is there a way to
avoid communication via stubs/skelettons and access directly the EJBs ?
Thanks for your help.
Similar Messages
-
I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?
Jonas,
I think what you want is a 3D plot of a cylinder. I have attached an example using a parametric 3D plot.
You will probably want to duplicate the points for the first theta value to close the cylinder. I'm not sure what properties of the graph can be manipulated to make it easier to see.
Bruce
Bruce Ammons
Ammons Engineering
Attachments:
Cylinder_Plot_3D.vi 76 KB -
Nested for loop in the collections
Hi Experts,
collection1
============
SELECT o.object_id
BULK COLLECT INTO l_obj_info
FROM (SELECT n.node_id, n.object_id
FROM nodes n
START WITH n.node_id = 100
CONNECT BY PRIOR n.node_id = n.parent_node_id) n
INNER JOIN
objects o ON n.object_id = o.object_id
WHERE o.object_type_id = 285;
collection2
============
SELECT *
BULK COLLECT INTO l_tab
FROM ((SELECT REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
FROM DUAL
CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
END;
collection3
============
SELECT o.object_id
BULK COLLECT INTO l_fin_tab
FROM objects o JOIN ATTRIBUTES att
ON o.object_id = att.object_id
WHERE o.object_id = collection1.object_id
--AND att.VALUE = collection2.val;
Please tell me how to implement for loop in the collection3 to get the values from collection1 and collection2.
i have tried in the below way
CREATE OR REPLACE TYPE LIST_OF_ATTRIBUTES_TYPE AS TABLE OF varchar2(4000);
CREATE OR REPLACE TYPE LIST_OF_OBJECT_IDS_TYPE AS TABLE OF number(9);
CREATE OR REPLACE FUNCTION f_get_objects_by_type_id (
i_object_type_id IN NUMBER,
i_l_text IN VARCHAR2,
i_scope_node_id NUMBER
RETURN list_of_object_ids_type
AS
CURSOR objs_info
IS
SELECT o.object_id
FROM (SELECT n.node_id, n.object_id
FROM nodes n
START WITH n.node_id = i_scope_node_id
CONNECT BY PRIOR n.node_id = n.parent_node_id) n
INNER JOIN
objects o ON n.object_id = o.object_id
WHERE o.object_type_id = i_object_type_id;
l_tab list_of_attributes_type := list_of_attributes_type ();
--l_obj_info list_of_object_ids_type := list_of_object_ids_type ();
l_fin_tab list_of_object_ids_type := list_of_object_ids_type ();
BEGIN
BEGIN
SELECT *
BULK COLLECT INTO l_tab
FROM ((SELECT trREGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
FROM DUAL
CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
END;
IF l_tab.COUNT > 0
THEN
FOR i IN objs_info
LOOP
FOR j IN l_tab.FIRST .. l_tab.LAST
LOOP
SELECT o.object_id
BULK COLLECT INTO l_fin_tab
FROM objects o JOIN ATTRIBUTES att ON o.object_id =
att.object_id
WHERE
att.VALUE = l_tab (j) and o.object_id =objs_info(i);
END LOOP;
END LOOP;
END IF;
RETURN l_fin_tab;
END f_get_objects_by_type_id;Why are you wanting to do this?
It looks like you are trying to implement SQL joins in PL code. Not only is that using up expensive PGA memory by storing the data in collections, but doing such retrieval of data to try and join it in PL loops, is never going to be as fast as just joining the SQL queries using SQL itself.
Post some example data and your database version, with an example of what the output should look like from that example data.
Re: 2. How do I ask a question on the forums? -
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 -
Which is better??? for loop or bulk collect
declare
cursor test is
select * from employees;
begin
open test;
loop
exit when test%notfound;
fetch test into myvar_a(i); CASE A
i:=i+1;
end loop;
close test;
open test;
fetch test bulk collect into myvar_b; CASE B
close test;
end;
Which case is better?? A or B?
Edited by: Kakashi on May 31, 2009 12:54 AMDepends on the meaning of better.
Generally case B should be faster although a bit more elaborate code is required.
But there may be exceptions. I think I read somewhere (I'm home now and I cannot find it at the moment) that in 10g (or 11g - not sure) 100 rows at a time are pre-fetched behind scenes even when you use case A. So using case B with a low limit could well be slower.
If I can express an additional opinion case F(irst) is nearly always the best i.e. plain SQL (no loops at all). I'm aware that sometimes it cannot be used, but should be the first approach to be tried.
Regards
Etbin
FOUND: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:213366500346264333
CONTAINS
Hey Tom, love the site. I noticed in your first fetch, which was in the first for loop that did an unconditional exit:
2 for x in ( select rownum r, t1.* from big_table.big_table t1 )
3 loop
4 exit;
5 end loop;
In looking at the TKPROF output for that query, it shows the number of rows being fetched as 100. Does that prove / demonstrate the bulk collecting optimization that Oracle added in 10g, where it implicitly and automatically does a bulk collect of limit 100 behind the scenes?
This came up at a discussion at my site very recently, and I think I can just point them to your example here as a demo rather than creating my own. I assume that if you ran the same thing in 9iR2, then that first fetch of rows in TKPROF would only show 1?
Followup April 18, 2007 - 1pm US/Eastern:
yes, that demonstrates the implicit array fetch of 100 rows...
in 9i, it would show 1 row fetched.
Edited by: Etbin on 31.5.2009 10:38 -
Doubt in Looping over a collection...?
Hello,
As i was goin through some collections topics .. i have understood the basics, but i am NOT able to understand this line ... *" l_tab(l_tab.last) := i; "*
DECLARE
TYPE t_tab IS TABLE OF exception_test.id%TYPE;
l_tab t_tab := t_tab();
BEGIN
-- Fill the collection.
FOR i IN 1 .. 100 LOOP
l_tab.extend;
l_tab(l_tab.last) := i;
END LOOP;
End;
Why it is assigning like ' l_tab.LAST '.....?? y not from FIRST place....???
ThanksAijaz Mallick wrote:
Tht's Correct ... But why only LAST & why not FIRST....???Perhaps if you look at the contents while you do it, you'll get an idea...
SQL> ed
Wrote file afiedt.buf
1 declare
2 type t_coll is table of integer;
3 v_coll t_coll := t_coll();
4 --
5 procedure show_coll is
6 v_str varchar2(2000);
7 begin
8 for x in 1..v_coll.last
9 loop
10 v_str := ltrim(v_str||','||v_coll(x),',');
11 end loop;
12 dbms_output.put_line('Array Size: '||to_char(v_coll.last,'99')||' : '||v_str);
13 end;
14 --
15 begin
16 for i in 1..10
17 loop
18 v_coll.extend;
19 v_coll(v_coll.last) := i;
20 show_coll;
21 end loop;
22* end;
SQL> /
Array Size: 1 : 1
Array Size: 2 : 1,2
Array Size: 3 : 1,2,3
Array Size: 4 : 1,2,3,4
Array Size: 5 : 1,2,3,4,5
Array Size: 6 : 1,2,3,4,5,6
Array Size: 7 : 1,2,3,4,5,6,7
Array Size: 8 : 1,2,3,4,5,6,7,8
Array Size: 9 : 1,2,3,4,5,6,7,8,9
Array Size: 10 : 1,2,3,4,5,6,7,8,9,10
PL/SQL procedure successfully completed.Whereas, if you where using FIRST instead of LAST, you'd get...
SQL> ed
Wrote file afiedt.buf
1 declare
2 type t_coll is table of integer;
3 v_coll t_coll := t_coll();
4 --
5 procedure show_coll is
6 v_str varchar2(2000);
7 begin
8 for x in 1..v_coll.last
9 loop
10 v_str := ltrim(v_str||','||v_coll(x),',');
11 end loop;
12 dbms_output.put_line('Array Size: '||to_char(v_coll.last,'99')||' : '||v_str);
13 end;
14 --
15 begin
16 for i in 1..10
17 loop
18 v_coll.extend;
19 v_coll(v_coll.first) := i;
20 show_coll;
21 end loop;
22* end;
SQL> /
Array Size: 1 : 1
Array Size: 2 : 2,
Array Size: 3 : 3,,
Array Size: 4 : 4,,,
Array Size: 5 : 5,,,,
Array Size: 6 : 6,,,,,
Array Size: 7 : 7,,,,,,
Array Size: 8 : 8,,,,,,,
Array Size: 9 : 9,,,,,,,,
Array Size: 10 : 10,,,,,,,,,
PL/SQL procedure successfully completed.
SQL> -
Looping Over the Collection elements in the BPEL
Hi Everybody,
Note:It appears this thread long paragraph but those are schems structures only.I am giving them to give full depth of my req.
1) First requirement :I have requirement wherein I have to retrieve the Data from Database adapter and modify it according to my requirements like below.
1) Input data from Database Adapter example: (Initial Schema)
<select_arrid_collection xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/Select_Arrid">
<select_arrid>
<arr_id>arr1</arr_id>
</select_arrid>
<select_arrid>
<arr_id>arr2</arr_id>
</select_arrid>
<select_arrid>
<arr_id>arr1</arr_id>
</select_arrid>
<select_arrid>
<arr_id>arr2</arr_id>
</select_arrid>
</select_arrid_collection>
2) I am modifying to get the collection objects based on element same arr_id(If it is arr1,I have to get the all the elements related arr1 into one of the collection Object that is select_arrid_collection.Likewise for any arr_id ,it has to group them into a select_arrid_collection element) like below:
Modified schema:
<root xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/Select_Arrid">
<select_arrid_collection>
<select_arrid>
<arr_id>arr1</arr_id>
</select_arrid>
<select_arrid>
<arr_id>arr1</arr_id>
</select_arrid>
</select_arrid_collection>
<select_arrid_collection>
<select_arrid>
<arr_id>arr2</arr_id>
</select_arrid>
<select_arrid>
<arr_id>arr2</arr_id>
</select_arrid>
</select_arrid_collection>
</root>
Note: root element is added in the schema that is why this modified xml has different namespace
I am using below xsl file to get the above schema to get the solution for first requirement:
<xsl:stylesheet version="2.0" xmlns:ns1="http://www.example.org" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ns1:root>
<xsl:for-each-group select="*/ns1:Select_Arrid" group-by="ns1:Arr_id">
<xsl:sort select="current-grouping-key()">
<ns1:select_arrid_collection>
<xsl:copy-of select="current-group()">
<xsl:apply-templates/>
</xsl:copy-of>
</ns1:select_arrid_collection>
</xsl:sort>
</xsl:for-each-group>
</ns1:root>
</xsl:template>
</xsl:stylesheet>
2) Second requirement:
After getting the multiple collection elements(select_arrid_collection),I want to loop through each select_arrid_collection element and map the elements in that to another service schema.
I have created the xsd like above required modified schema and assign it to a variable(element type) which takes same modified schema so that I can have a variable on which I want to apply while activity.
But I want to have the idea how to loop through the multiple collection elements(select_arrid_collection) and map the elements of each select_arrid_collection to a input variable of a service.
My problem is I have to get each select_arrid_collection element in the schema where root element is 'root'.I am not able to trace how to get the no of select_arrid_collection elements so that I can loop through in the transofrm activity.
Can anybody help me put in this?
Edited by: 899283 on Jan 9, 2013 1:48 AM
Edited by: 899283 on Jan 9, 2013 1:52 AM
Edited by: 899283 on Jan 9, 2013 1:53 AM
Edited by: 899283 on Jan 9, 2013 2:02 AMCan you please let us know if there are some helpful/correct answers in your previous questions and follow the forum etiquette? https://forums.oracle.com/forums/ann.jspa?annID=893
Where Can I create Staging table in SOA server?
regarding sending response at a time to a WSDL in BPEL
Do we need nodemanager for SOA server installation?
I want to set the time for polling of DB Adapter -
Loop Problems: data collection being halted by program excecution.
Sorry for the vague subject line, I'm finding it difficult to specify exactly what my problem is, so I'll start with what I want to happen. I'm working in a lab in which we are studying pain. The specifics are not mine to disclose but suffice it to say that based on certain input given by the subject we want to excecute a piece of hardware. The goal is to do this on a second to second basis, so if the subjects input warrants excecution in one second, the hardware will excecute for the next second, and will continue if the requirements continue to be met. I have programs both for recieving subject data, and for excecuting the hardware, the issue is that the conditions are being measured with a while loop, and the hardware is also excecuted with a while loop, so when the conditions are met the hardware activates and data stops being collected. I havnt figured out a way around this and I'm wondering if anyone can help me.
"There will be water if God wills it"Yeah, if you get the data flow to work right, these will run simultaneously. To get that information across loops, try using Local Variables. They can be memory-heavy if you use too many, but they could help you here.
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/creating_local_variables/
Ravi A.
National Instruments | Applications Engineer -
Can you loop through a collection of entites to read a given attribute?
I got an entity called <b>the applicant</b>. and this entity has an attribute called <b>the full name of the applicant</b>.
I want to go through the collection of <b>the applicants</b> and get the <b>full name</b> for each applicant and assign it to a text variable with comma seperated. Is it possible to do this in OPA?
this is what i want to do
<b>"the names" </b>is the variable that I want to store the list of names
read the collection of applicants
the names = the concatenation of the names & " " & the full name of the applicant & ","
end
so it will give me an output like <b>James Blunt, David Brown, Julia Guilard</b>
Edited by: Davin Fifield on Oct 16, 2011 10:57 PM - removed inappropriate "moderation" editWow harsh moderation there by rukbat! I don't know who he/she is but I apologise and assure you most people on this forum are not so mean.
To answer your question, there's no built-in way to do what you want. Normally displaying something like this would be considered an application problem rather than a rule-level problem, however if you really want it done in a rule, you could do it with a custom function. -
Why error when looping a sheets collection and setting the visible property?
I get an error on line 5 when running the following code:
1Sub ShowSheets(vSheets() As Variant)
2
3 Dim i As Long
4 For i = LBound(vSheets, 1) To UBound(vSheets, 1)
5 ThisWorkbook.Sheets(vSheets(i, 1)).Visible = xlSheetVisible
6 Next i
7
8End Sub
The error code I get is:
Run-time error '-2147417848 (80010108)':
Method 'Visible' of object '_Worksheet' failed
I only get the error when at least one of the sheets is a chart. But the error does not occur when the chart object is looping. Instead it occurs when the first worksheet object after the chart object is looping.
What is the cause of this error?Hi JP3O,
>> only get the error when at least one of the sheets is a chart. But the error does not occur when the chart object is looping<<
I am trying to reproduce this issue however failed. From the error message, it seems that the visible couldn't set when you call the sub.
How the code was executed? Would you mind sharing more detail about this secnario?
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Loop through the collection of elements and give 15 elements in each iteration.
For example I have 100 pnr numers and i need 15 set of pnrs each time i iterate through the 100 pnrs using XQUERY.
I have to hit a service to get PNR details , I have 100 PNR's but I can hit only with 15 at a timeHello,
Did the issue resolved? Just as Visakh16 post above, it is hard to interpret without the sample data. Please post more details for further analysis.
You can refer to the following article about FLWOR Statement and Iteration in XQuery:
http://technet.microsoft.com/en-us/library/ms190945.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
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 -
Hello I need to loop through the collection to process 500 records at a time from the resultset.
how do i do this?
I have created another variable of same type as resultset output variable type. but not sure how to assign nodes 1 to 1000 to the new variable.Hi,
You can loop over your collection with a while loop. The following is from the bpel samples directory (112.Arrays) adapted to your needs. Define the variables:
<variable name="iterator" type="xsd:integer"/>
<variable name="count" type="xsd:integer"/>
<variable name="xpath" type="xsd:string"/>
Set the initial values:
<assign name="SetInitialValues">
<copy>
<from expression="1"/>
<to variable="iterator"/>
</copy>
<copy>
<from expression="ora:countNodes('input', 'payload','/tns:collection/tns:item')"/>
<to variable="count"/>
</copy>
</assign>
Make a while loop:
<while condition=" bpws:getVariableData('count') >= bpws:getVariableData('iterator')">
<sequence>
<assign name="setAttribute">
<copy>
<from expression="concat('/tns:collection/tns:item[',bpws:getVariableData('iterator'),']/tns:value')"/>
<to variable="xpath"/>
</copy>
<copy>
<from expression="bpws:getVariableData('input','payload',bpws:getVariableData('xpath'))/>
<to variable="output" part="payload" query="/tns:recordVariable/tns:value"/>
</copy>
<!--
Place here your own actions to be executed for every row
-->
<copy>
<from expression="bpws:getVariableData('iterator') + 1"/>
<to variable="iterator"/>
</copy>
</assign>
</sequence>
</while>
So the trick is to dynamically build an xpath expression based on the while loop counter.
Kind Regards,
Andre -
Looping through Collection and getting ConcurrentModificationException
I'm trying to loop through a collection to delete some objects referenced by that collection but keep coming up against a ConcurrentModificationException.
BwView view = svci.getViewsHandler().find("Lists");
Collection<BwSubscription> subarr = new TreeSet<BwSubscription>();
subarr = svci.getSubscriptionsHandler().getAll();
if (subarr == null) {
logger.info("Its not working");
for (BwSubscription sub: subarr) {
logger.info("Removing subs " + sub);
svci.beginTransaction();
svci.getSubscriptionsHandler().delete(sub);
logger.info("Deleting calendars :" + sub);
svci.endTransaction();
The loop is allowing me to delete the first entry but then fails with the exception.
I have tried with a generic loop but this doesn't initialise the sub entity so the loop fails and is ignored leading to problems later in the code.
BwView view = svci.getViewsHandler().find("Lists");
BwSubscription[] subarr = (BwSubscription[])view.getSubscriptions().toArray(new BwSubscription []{});
if (subarr == null) {
logger.info("Its not working");
for (int i=subarr.length - 1; i>=0; i--) {
sub = subarr;
logger.info("Removing subs " + sub);
svci.beginTransaction();
svci.getSubscriptionsHandler().delete(sub);
logger.info("Deleting calendars :" + sub);
svci.endTransaction();
Sub is either not initialised or gets initialised as 0 causing an ArrayIndexOutofBoundsException. I'd be grateful for some advice on getting the code to loop correctly.While iterating over a collection (using its iterator), a ConcurrentModificationException will be thrown if the collection is modified, except if it is modified using the iterator itself.. The enhanched for-loop you're using is iterating over the collection by implicitly using an Iterator. To do what you want, make the Iterator explicit (change the enhanced for-loop to a while loop) and then use iterator.remove().
-
Looping through collection of symbols and populating a drop down on a form EXTENDSCRIPT
Hello everyone-
I got a question. Would it be possible to run a script that would loop through a collection of symbols in a defined library and populate a drop down with the available symbols. My goal is to be able to open Illustrator, and when I run the script the dropdown is populated with all available symbols(text is fine) in a defined library that I can then select and place on the artboard. Any help would be appreciated.
thanks in advance!So...
Dim appref As New Illustrator.Application
Dim docRef As Illustrator.Document 'The work document
Dim docToAdd As Illustrator.Document 'The document which contain the symbol's library
Dim pathArt As Object
Dim ItemSymbol As Object
Dim itemSymbolref As Illustrator.Symbol
Dim artObject As Variant
appref.Open ("C:\..... workDoc.ai")
Set docRef = appref.ActiveDocument 'Assign docRef to your work document
appref.Open ("C:\......symbolDoc.ai")
Set docToAdd = appref.ActiveDocument 'Assign docToAdd to your symbol document
Set symbolref = appref.ActiveDocument.Symbols(Symbol_Name) 'Assign symbol ref the symbol you're looking for
Set itemref = appref.ActiveDocument.SymbolItems.Add(symbolref) 'Copy it on the current active page
itemref.Selected = True 'select it
docToAdd.Copy 'add it to your clibboard
docToAdd.close (aiDoNotSaveChanges) 'Close the library, without changing anything
appref.ActiveDocument.Paste 'Paste the clipboard on your work document
'As soon as you paste the symbol, it will be added in the document symbol library
Clipboard_Clear 'See below why...
SelectedObjects =appref.ActiveDocuments.selection ' Select the symbol you past
' The loop is not necessary if you have only one thing selected
For Each artObject In selectedObjects
artObject.Delete
Next
' Cleanup your pointers
Set artObject = Nothing
Set pathArt = Nothing
Set docToAdd = Nothing
[....] Continue your script on your working document
Set docRef = Nothing 'after closing your working doc...
Remark on clipboard_clear : If you don't do it, the risk is to accumulate plenty other things you don't want...
Public Function ClipBoard_Clear()
Call OpenClipboard(0&)
Call EmptyClipboard
Call CloseClipboard
End Function
With
Public Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Public Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Public Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long
be careful I use the PtrSafe pointer due to the fact I'm working in x64 architecture
in x86 it will be
Public Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Regards to all
Michel
Maybe you are looking for
-
Can't create a wireless network without a wireless card on my Mac
Help! O.k. I tried searching the forums for an answer but the odd nature of my problem, and the immense database of topics made it very difficult to find a similar post. The general issue/idea: Run a wireless network using Airport Extreme - Connect d
-
Close Rows in Purchase Order And Sales Order
Hi, My user account is set as super user with all the access right. I manage to close rows in PO and SO but some of my colleague which is not a super user don't have the Close Rows right when we want to close an item in the document rows instead of D
-
User Defined Object Child Item Updating
Hi Team, May i know how can i update the particular child item in UDO tables. In Between, i will check if existing item is not found, i will add a new child If IsNewItem Then 'Add Child oChild = oAF_SPL1.Add
-
Move Catalog Album 2 to Elements 5
I have assembled about 7500 photos on Album. Up until now I have had to move each photo I wish to work on to Elements 3 for editing. I am installing Elements 5 (as soon as I can get rid of the error message 1327 Invalid drive E). I have 2 issues: 1.
-
Transferring pictures/albums from Photos to Finder and Flickr
I am currently running OS X 10.10.3 which now has Photos. I am trying to transfer albums to folders in Finder in order to send individual pictures as e-mail attachments as well as upload pictures/albums to Flickr. However, I am seemingly unable to ei