Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Dynamic SQL

Re: Dynamic SQL

From: Michel Cadot <micadot_at_netcourrier.com>
Date: 2000/04/11
Message-ID: <8cvek6$13be$1@news6.isdnet.net>#1/1

Add a raise statement in your exception block, that will give the reason of the failure: ...
EXCEPTION
when others then

   dbms_sql.close_cursor(cursor_name);
   raise;
END exec;
/

--
Michel


ykhlef Mourad <ykhlef_at_yahoo.fr> a écrit dans le message : 38F33148.4441C472_at_yahoo.fr...

> My procedure works fine when
> i do not pass a string that create a table.
>
> If i have a table T the
> following command
> exec('alter T add(b integer)')
> works fine
>
> But exec('create table myT(id integer)') faills
>
> That is all
>
> Michel Cadot a écrit :
>
> > So it doesn't work but what is the error?
> > Tell us more.
> >
> > --
> > Michel
> >
> > ykhlef Mourad <ykhlef_at_yahoo.fr> a écrit dans le message : 38F31E29.434D79B6_at_yahoo.fr...
> > > Hi,
> > >
> > > Here is my dynamic storage procedure exec.
> > >
> > > CREATE OR REPLACE PROCEDURE exec(theString in varchar2) as
> > > cursor_name INTEGER;
> > > rows_processed INTEGER;
> > > BEGIN
> > > cursor_name := dbms_sql.open_cursor;
> > > dbms_sql.parse(cursor_name, theString, dbms_sql.v7);
> > > rows_processed := dbms_sql.execute(cursor_name);
> > > dbms_sql.close_cursor(cursor_name);
> > > EXCEPTION
> > > when others then
> > > dbms_sql.close_cursor(cursor_name);
> > > END exec;
> > > /
> > >
> > > Probleme
> > > -------------
> > >
> > > The command
> > > execute exec('create table myT(a number(34))');
> > >
> > > works in SYS schema and does not in a user Schema :
> > >
> > > Note that the command
> > > execute exec('drop table client');
> > > works in a user schema
> > >
> > >
> > > Thank you in advance
> > > Mourad
> > >
> > >
>
Received on Tue Apr 11 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US