Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create a temporary table within a stored procedure

496074Mar 6 2006 — edited Mar 6 2006
QUESTION:

I have been told that the way to create a temporary table within an Oracle (9i here) stored procedure, to use

execute immediate 'create table temp_x (i int)';

I can create the stored procedure, but it does not execute.

I can successfully enter 'create table temp_x (i int) at a SQL*Plus prompt, and create a temporary table.

Any ideas about what to do to get this to work from within a stored procedure?

Details below.

David
BACKGROUND:

From an Oracle SQL*Plus prompt,I can create the temp table
(1) Proof that I am the DHFS test environment.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

(2) From SQL*Plus prompt, can create a temp table
SQL> create table temp_x (i int);
Table created.

(3) From SQL*Plus prompt, I can drop a regular table
SQL> drop table temp_x;
Table dropped.

(4) I then created a stored procedure:
CREATE OR REPLACE PROCEDURE FINEDL.CREATE_TEMP_TABLE
AS
BEGIN
execute immediate 'create table temp_x (i int)';
END;
created successfully

(5) Execute the stored procedure within Embarcadero DBArtisan tool
Error: ORA-01031: insufficient privileges ORA-06512: at line 1, Batch 1 Line 1 Col 1

(6) Execute the stored procedure from an Oracle SQL*Plus prompt
SQL> execute finedl.create_temp_table;
BEGIN finedl.create_temp_table; END;

*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "FINEDL.CREATE_TEMP_TABLE", line 4
ORA-06512: at line 1

ORA-01031 insufficient privileges
Cause: An attempt was made to change the current username or password without the appropriate privilege. This error also occurs if attempting to install a database without the necessary operating system privileges.

Action: Ask the database administrator to perform the operation or grant the required privileges.
ORA-06512 at string line string

Cause: Backtrace message as the stack is unwound by unhandled exceptions.

Action: Fix the problem causing the exception or write an exception handler for this condition. Or you may need to contact your application administrator or database administrator.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2006
Added on Mar 6 2006
2 comments
2,224 views