Hi,
I am trying to lern the handling of cursors: I wrote a procedure in which a cursor is
declared (see example below).
If I use OPEN CURSOR statement I get a -5015 error (Syntax error or access
violation;-5015 POS(1020) Missing keyword:THEN,FETCH,DO,CLOSE,CALL,WHILE,SE). If I leave
out the OPEN CURSOR statement the DBMS accepts the procedure and it seems to work as it
should.
I studied the documentation but I do not get it! Don't I have to open the cursor
(explicitly) before fetching the rows? When do I have to use the OPEN CURSOR statement?
If I leave out the CLOSE statement there seems to be no difference.
So long I thought cursor handling functions this way (simplified): DECLARE CURSOR -
OPEN CURSOR - FETCH DATA - PROCESS DATA - CLOSE CURSOR
Is there someone who is able to explain this to me?
<...>
DECLARE <cursor_name> CURSOR
FOR
SELECT <column_list>
FROM <table_owner>.<table_name>;
OPEN <cursor_name>;
FETCH FIRST <cursor_name> INTO <parameter_list>;
WHILE $RC <> 100 DO
BEGIN
<...>
FETCH NEXT <cursor_name> INTO <parameter_list>;
END;
CLOSE <cursor_name>;
<...>
Thank You in advance!
Frank Schimmelpfennig
PHILIPS Semiconductors Hamburg
ATO-PICTOH IT&DataSupport
Tel.: +49 40 5613 -1835, Fax: -3020
| Thread |
|---|
| • OPEN CURSOR statement, FETCH statement, CLOSE statement | frank.schimmelpfennig | 12 Dec |