Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> plsql help: dynamic cursor with params
Hi,
I'm trying to do this:
TYPE cur_type IS REF CURSOR;
my_cursor cur_type;
my_sql VARCHAR(2000) := 'select col_1, col_2, col_n, from '||v_table||'
where col_a = :var_a AND col_b = :var_b';
....
OPEN my_cursor FOR my_sql USING (var1, var2);
FETCH my_cursor INTO (dat1, dat2, datn) LOOP
....
Oracle complains "Encountered my_sql when expecting select"
I won't know the where condition variables or the table name until run-time so they have to be dynamic. I think this is the only way to accomplish this. Also, this may return many rows.
Any ideas on how to get this to work? Many thanks in advance!
-Dan
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Sep 15 2000 - 08:33:48 CDT
![]() |
![]() |