Re: How to make dynamic SQL in PL/SQL ?

From: Steve Hoffman <steve#m#_dave_at_msgate.corp.apple.com>
Date: 1995/04/13
Message-ID: <steve#m#_dave-130495125605_at_17.25.26.13>#1/1


In article <3m3dpa$i9d_at_ccpnws.in2p3.fr>, chaleat_at_cc.in2p3.fr (Philippe Chaleat) wrote:
>
> Hello,
>
> I want to create the WHERE clause of a query into a PL/SQL procedure,
> as it can be done in Pro*C. Is it possible ?
>
>
> Thanks...

DECLARE
   curs1 INTEGER;
   curs_execute INTEGER;
   max_sal INTEGER;
   sql_stmnt VARCHAR2(100);

BEGIN
   SELECT MAX(sal) INTO max_sal FROM emp;    curs1 := dbms_sql.open_cursor;
   sql_stmnt := 'UPDATE emp SET sal = sal + 1 WHERE sal = '||max_sal;

   dbms_sql.parse (curs1, sql_stmnt, dbms_sql.v7);
   curs_execute := dbms_sql.execute(curs1);
   dbms_sql.close_cursor(curs1);

END;
/

Steve Hoffman Consulting at Apple Computer Received on Thu Apr 13 1995 - 00:00:00 CEST

Original text of this message