Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ?




From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL statements.

Eg: CREATE OR REPLACE PROCEDURE DYNSQL

AS

cur integer;

rc integer;

BEGIN

cur := DBMS_SQL.OPEN_CURSOR;

DBMS_SQL.PARSE(cur,’CREATE TABLE X (Y DATE)’, DBMS_SQL.NATIVE);

rc := DBMS_SQL.EXECUTE(cur);

DBMS_SQL.CLOSE_CURSOR(cur);

END;

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>