Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Cursor with dynamic query
Something like :
temp_cur integer;
temp_count number;
Status integer;
num_recs integer;
begin
temp_cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(temp_cur,'select count(distinct '||col_name||') from
'||tab_name
||' where '||where_qry,
DBMS_SQL.NATIVE);
DBMS_SQL.DEFINE_COLUMN (Temp_Cur, 1, Temp_Count);
Status := DBMS_SQL.EXECUTE (Temp_Cur);
IF (DBMS_SQL.FETCH_ROWS (Temp_Cur) > 0) THEN
DBMS_SQL.COLUMN_VALUE (Temp_Cur, 1, Temp_Count);
num_recs := Temp_Count;
END IF;
DBMS_SQL.CLOSE_CURSOR (Temp_Cur);
.....
Yann
Vigi98 a écrit dans le message ...
>Hello all,
>
>I'm used to write "OPEN cursor FOR SELECT tata FROM toto;" where cursor is
a
>cursor.
>
>Now, I would like to do the same with a dynamic query, something like
>"OPEN cursor FOR v_query;"
>where v_query is a VARCHAR containing the query.
>
>How to do that ? PL/SQL does not accept this syntax.
>
>Thanks for all your answers.
>
>
>
>
>
Received on Tue Aug 21 2001 - 05:04:47 CDT