Subject | Re[4]: [firebird-support] nested cursors in 1.5.x |
---|---|
Author | André Knappstein, Controlling |
Post date | 2009-06-18T10:58:24Z |
Hello Vlad,
VK> Are you sure inner cursor produced records ?
absolutely.
a.)
if an order consists of 4 shipments (3 partial shipments and the final
shipment), I will get the final shipment from the outer cursor and 3
additional rows from the inner cursor. If an order only consists of 1
shipment, I get only one row, and so on...
I did a lot of tests and the total number of rows per order always is
1 + np, where np = correct number of partial shipments before the last
shipment.
b.)
if I do not "re-use" output parameters output1/output2, but create
additionally output3/output4 and leave op1/op2 untouched, it works
fine. But the requirement is to have the values of outer and inner
cursor in the same output columns.
I can give you 2 examples - from memory of yesterday.
If 2 cursors on the same table SHOULD work in Firebird 1.5.4 then I
will prepare a working testcase and thereby probably find out what's
wrong in my code or in my database :)
I probably will do it in any case as soon as I find the time, and also
then test it with 2.1
The following works fine, but I can't use this order of rows:
=============================================================
For
Select a.Field1, a.Field2 from TheTable a where a.x= :y into :V1, :V2
do
begin
-- send the main row to output
output1 = :V1;
output2 = :V2;
suspend;
-- look in same table for n rows belonging to main row
For
Select b.Field1, b.Field3 from TheTable b where b.IDProcess = :V2
into :V3, :V4
do
begin
output3 = :V3;
output4 = :V4;
suspend;
end
end
result looks like this (1 final + 3 partial shipments)
op1 op2 op3 op4
001 p1 null null
001 p1 002 x
001 p1 003 y
001 p1 004 z
The following does _NOT_ work (note that I just add one line to inner
cursor)
=====================================================================
For
Select a.Field1, a.Field2 from TheTable a where a.x= :y into :V1, :V2
do
begin
-- send the main row to output
output1 = :V1;
output2 = :V2;
suspend;
-- look in same table for n rows belonging to main row
For
Select b.Field1, b.Field3 from TheTable b where b.IDProcess = :V2
into :V3, :V4
do
begin
output3 = :V3;
output4 = :V4;
output1 = :V3;
suspend;
end
end
Now the result probably looks like this:
op1 op2 op3 op4
001 p1 null null
001 p1 001 x
001 p1 001 y
001 p1 001 z
(op3 has the results from outer cursor, not from inner)
thanks!
ciao,
André
~~~Ihre Nachricht~~~
VK> Regards,
VK> Vlad
VK> ------------------------------------
VK> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VK> Visit http://www.firebirdsql.org and click the Resources item
VK> on the main (top) menu. Try Knowledgebase and FAQ links !
VK> Also search the knowledgebases at http://www.ibphoenix.com
VK> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VK> Yahoo! Groups Links
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beta Eigenheim- und Grundstücksverwertungsgesellschaft mbH
Hafenweg 4
59192 Bergkamen-Rünthe
Telefon: +49 2389 9240 0
Telefax: +49 2389 9240 150
e-mail: info@...
Amtsgericht Hamm Nr. B 420 || USt-IDNr.: DE 125215402
Geschäftsführer: Achim Krähling, Dirk Salewski, Matthias Steinhaus
VK> Are you sure inner cursor produced records ?
absolutely.
a.)
if an order consists of 4 shipments (3 partial shipments and the final
shipment), I will get the final shipment from the outer cursor and 3
additional rows from the inner cursor. If an order only consists of 1
shipment, I get only one row, and so on...
I did a lot of tests and the total number of rows per order always is
1 + np, where np = correct number of partial shipments before the last
shipment.
b.)
if I do not "re-use" output parameters output1/output2, but create
additionally output3/output4 and leave op1/op2 untouched, it works
fine. But the requirement is to have the values of outer and inner
cursor in the same output columns.
I can give you 2 examples - from memory of yesterday.
If 2 cursors on the same table SHOULD work in Firebird 1.5.4 then I
will prepare a working testcase and thereby probably find out what's
wrong in my code or in my database :)
I probably will do it in any case as soon as I find the time, and also
then test it with 2.1
The following works fine, but I can't use this order of rows:
=============================================================
For
Select a.Field1, a.Field2 from TheTable a where a.x= :y into :V1, :V2
do
begin
-- send the main row to output
output1 = :V1;
output2 = :V2;
suspend;
-- look in same table for n rows belonging to main row
For
Select b.Field1, b.Field3 from TheTable b where b.IDProcess = :V2
into :V3, :V4
do
begin
output3 = :V3;
output4 = :V4;
suspend;
end
end
result looks like this (1 final + 3 partial shipments)
op1 op2 op3 op4
001 p1 null null
001 p1 002 x
001 p1 003 y
001 p1 004 z
The following does _NOT_ work (note that I just add one line to inner
cursor)
=====================================================================
For
Select a.Field1, a.Field2 from TheTable a where a.x= :y into :V1, :V2
do
begin
-- send the main row to output
output1 = :V1;
output2 = :V2;
suspend;
-- look in same table for n rows belonging to main row
For
Select b.Field1, b.Field3 from TheTable b where b.IDProcess = :V2
into :V3, :V4
do
begin
output3 = :V3;
output4 = :V4;
output1 = :V3;
suspend;
end
end
Now the result probably looks like this:
op1 op2 op3 op4
001 p1 null null
001 p1 001 x
001 p1 001 y
001 p1 001 z
(op3 has the results from outer cursor, not from inner)
thanks!
ciao,
André
~~~Ihre Nachricht~~~
>> The abstract of the turnkey is like this:VK> Are you sure inner cursor produced records ?
>> For
>> Select a.Field1, a.Field2 from TheTable a where a.x=3D:y into :V1, :V2
>> do
>> begin
>> -- send the main row to output
>> output1 =3D :V1;
>> output2 =3D :V2;
>> suspend;
>>
>> -- look in same table for n rows belonging to main row
>> For
>> Select b.Field1, b.Field2 from TheTable b where b.IDProcess =3D :V2
>> into :V3, :V4=20
>> do
>> begin
>> output1 =3D :V3;
>> output2 =3D :V4;
>> suspend;
>> end
>> end
>>
>> output1/output2 are the returning values/output parameters.
>>
>> The error is in the values of output1/output2 in the 2nd cursor.
>> For each row of the 2nd cursor they do NOT have the values :V3/:V4 of
>> the inner cursor's position, but :V1/:V2 (of the outer cursor's
>> position)
VK> Regards,
VK> Vlad
VK> ------------------------------------
VK> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VK> Visit http://www.firebirdsql.org and click the Resources item
VK> on the main (top) menu. Try Knowledgebase and FAQ links !
VK> Also search the knowledgebases at http://www.ibphoenix.com
VK> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VK> Yahoo! Groups Links
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beta Eigenheim- und Grundstücksverwertungsgesellschaft mbH
Hafenweg 4
59192 Bergkamen-Rünthe
Telefon: +49 2389 9240 0
Telefax: +49 2389 9240 150
e-mail: info@...
Amtsgericht Hamm Nr. B 420 || USt-IDNr.: DE 125215402
Geschäftsführer: Achim Krähling, Dirk Salewski, Matthias Steinhaus