At 08:28 PM 11/15/01 -0800, Ben Strickland wrote:

>>>>
Has anyone had experience with two files running
one after another and both files use the Declare
Cursor and for some reason I have to run the second
file twice to get the Declare Cursor and other
commands in the file to work. Any answers?



Ben,

01. Make sure to DROP the CURSOR and CLEAR ALL VAR accordingly
after the ENDWHILE.

02. Re-Define ALL VARIABLES with appropriate DATA TYPES as
NULL prior to DECLARing CURSOR, using OPEN FETCH cursor
and FETCH cursor INTO command.

Simple Example:

SET VAR VColumn1 TEXT = NULL
SET VAR VColumn2 INTEGER = NULL
SET VAR VColumn3 CURRENCY = NULL
SET VAR VColumn4 DATE = NULL

SET ERROR MESSAGE 705 OFF
DROP CURSOR C#1

DECLARE C#1 CURSOR FOR SELECT Column1,Column2,Column3,Column4 +
FROM Tablename WHERE ..... ORDER BY .....

OPEN C#1
FETCH C#1 INTO +
VColumn1 INDIC IColumn1, +
VColumn2 INDIC IColumn2, +
VColumn3 INDIC IColumn3, +
VColumn4 INDIC IColumn4


WHILE SQLCODE <> 100 THEN

-- Do what you have to do here ...

SET VAR VColumn1 = NULL
SET VAR VColumn2 = NULL
SET VAR VColumn3 = NULL
SET VAR VColumn4 = NULL

FETCH C#1 INTO +
VColumn1 INDIC IColumn1, +
VColumn2 INDIC IColumn2, +
VColumn3 INDIC IColumn3, +
VColumn4 INDIC IColumn4
ENDWHILE
DROP CURSOR C#1
SET ERROR MESSAGE 705 ON
-- CLEAR VARIABLES accordingly

Have Fun!

Very Best Regards,

Razzak.



===================================-============================
Official R:BASE List Server: mailto:[EMAIL PROTECTED]
RBTI Events/Training: http://www.rbase2000.com/events
R:DCC Members: http://www.rbase2000.com/rdcc
================================================================
R:BASE, Oterro & R:Tango are registered trademarks of RBTI.
==================================-=============================

Reply via email to