Click here to Skip to main content
15,904,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI i want to create a procedure in which i can create a table.
so i have done this
SQL
CREATE OR REPLACE PROCEDURE test_proc

BEGIN
execute immediate 'CREATE TABLE ABC_TABLE AS SELECT * FROM XYZ_TABLE WHERE 1=0';
END;


but after compiling i get following error.


Encountered the symbol "BEGIN" when expecting one of the following: ( ; is with authid as cluster compress order using compiled wrapped external deterministic parallel_enable pipelined The symbol "is" was substituted for "BEGIN" to continue.


can any one tell me reason for this and how to create the table in procedure.

thanks in advance...
Posted

Is there any specific reason to create table in the procedure? I think you should create table only once outside your procedure and then use it in your procedure.

here is an example of select into..

http://www.mkyong.com/oracle/oracle-stored-procedure-select-into-example/[^]
 
Share this answer
 
Comments
preet88 9-Jul-12 8:16am    
yes i want to perform certain set of operation on selected data into the table
and then store that data into another one.
Pablo Aliskevicius 9-Jul-12 9:20am    
I thing you should consider using a temporary table for that purpose.
If you're coming to Oracle from SQL Server, note that Oracle temporary tables are different from SQL Server temporary tables in meaningful ways:
1. The tables are inside your database (no TEMPDB).
2. The table records are temporary, but the table structure is permanent: thus, it can be used in functions and procedures.
The similarity is that records are per-session.
A long, long time ago I had a similar need, creation of tables in a stored procedure, for the purpose of implementing 'the poor man's partition' (partitioning for customers with the humble editions of Oracle, back then partitioning was supported in the Luxury Gold Enterprise Edition, or whatever it was called).
Hope this helps,
Pablo.
preet88 9-Jul-12 9:34am    
thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900