Re: Cursor with dynamic query

From: Yann CAUCHARD <yann.cauchard_at_spcconsultants.com>
Date: Tue, 21 Aug 2001 12:04:47 +0200
Message-ID: <9ltbmu$a4n$1_at_news6.isdnet.net>


Something like :

temp_cur integer;
temp_count number;
Status integer;
[Quoted] 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 - 12:04:47 CEST

Original text of this message