Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Fetch out of sequence error in pro C recursive calls
Hi All,
I am trying to call a function recursively that creates an SQL
statement and executes it
and then calls itself. I get a fetch out of sequence error. When I
tried to modify the code
below for my use with
EXEC SQL DECLARE STMT STATEMENT;
EXEC SQL EXECUTE BEGIN OPEN :dyn_cursor for STMT;
END; END-EXEC;
EXEC SQL PREPARE STMT FROM :dynaString;
I get this error. How do I make a dynamic cursor that executes a
dynamic select
query ?
Error at line 945, column 49 in file oracle.pc EXEC SQL EXECUTE BEGIN OPEN :dyn_cursor for STMT;
................................................1PLS-S-00201, identifier 'STMT' must be declared Error at line 945, column 29 in file oracle.pc
I found the following peice of code here in an older thread. My problem is , how to make it work for a dynamic SQL query.
Thanks a lot
A newbie.
SQL_CURSOR my_cursor; VARCHAR ename[40]; int new_empno;
EXEC SQL ALLOCATE :my_cursor;
EXEC SQL EXECUTE BEGIN
if ( :empno = 0 ) then open :my_cursor for SELECT ENAME, EMPNO FROM EMP WHERE MGR IS NULL; else open :my_cursor for SELECT ENAME, EMPNO FROM EMP WHERE MGR = :empno; end if;
EXEC SQL WHENEVER NOTFOUND DO break; EXEC SQL FETCH :my_cursor INTO :ename, new_empno; printf( "%*.*s %.*s\n", depth, depth, " ", ename.len, ename.arr ); process( new_empno, depth+5 );
} Received on Fri Oct 13 2006 - 06:50:10 CDT
![]() |
![]() |