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

Home -> Community -> Usenet -> c.d.o.server -> Re: stored procedure: dinamically create / insert / drop table

Re: stored procedure: dinamically create / insert / drop table

From: Zdenek Oklestek <oklestek_at_datis.cdrail.cz>
Date: Fri, 21 May 2004 08:57:43 +0200
Message-ID: <40ada867.0@10.140.56.22>


Jon napsal(a):

> Hi,
>
> during a procedure execution I want to dinamically create a table and insert
> rows in this table.
>
> execute immediate 'create table X1...';
> insert into X1;
>
> when trying to compile the procedure the problem is that X1 table does not
> exist so I have to use dynamic SQL to do the INSERT . Is there any way to
> avoid this problem?
>
> thanks,
>
>

DECLARE
        lc_command VARCHAR2(100);
BEGIN

	lc_command := 'CREATE TABLE X1(X1_1 NUMBER(7))';
	EXECUTE IMMEDIATE lc_command;
	lc_command := 'INSERT INTO X1 VALUES(1)';
	EXECUTE IMMEDIATE lc_command;
	COMMIT;
EXCEPTION
	WHEN OTHERS THEN
		ROLLBACK;
		RAISE;

END;
/ Received on Fri May 21 2004 - 01:57:43 CDT

Original text of this message

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