Home » RDBMS Server » Server Administration » creat table by Dynamic SQL
creat table by Dynamic SQL [message #374922] Wed, 11 July 2001 16:49 Go to next message
George
Messages: 68
Registered: April 2001
Member
I like to create a table from this SP using 'CREATE TABLE ABC AS SELECT * FROM EMP' in Dynamic SQL, but failed. The create statements worked in SQL*PLUS:
procedure createtemp (
table_name VARCHAR2,
view_name VARCHAR2,
orderbystring IN VARCHAR2) AS
sql_statement VARCHAR2(1000);
BEGIN
sql_statement :='CREATE '| |table_name | |' AS SELECT a.*, rownum rn FROM '| |view_name | |' a ORDER BY :str' ;
EXECUTE IMMEDIATE sql_statement USING orderbystring;
END createtemp;

*** RUN THIS:

SQL> EXECUTE createtemp ('emptemp', 'emp', 'empno');
BEGIN empora.createtemp ('emptemp', 'emp', 'empno'); END;

*
ERROR at line 1:
ORA-00901: invalid CREATE command
ORA-06512: at "SCOTT.EMPORA", line 11
ORA-06512: at line 1

Can anybody help me to correct this?

Thanks
Re: creat table by Dynamic SQL [message #374926 is a reply to message #374922] Wed, 11 July 2001 21:09 Go to previous message
Cindy
Messages: 88
Registered: November 1999
Member
Hi Gray,

Here is a site may be able to help you out...ask your question there. I have seen very complex questions being answered.

http://asktom.oracle.com/pls/ask/f?p=4950:1:182291

Good luck,
Cindy
Previous Topic: Re: Simple Update
Next Topic: Constraint
Goto Forum:
  


Current Time: Wed Jul 03 03:13:07 CDT 2024