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

Home -> Community -> Usenet -> c.d.o.misc -> Dynamic SQL and Privileges

Dynamic SQL and Privileges

From: <lrako_at_hotmail.com>
Date: Tue, 20 Oct 1998 14:12:02 GMT
Message-ID: <70i5ni$ir5$1@nnrp1.dejanews.com>


Dear all ,

I've written a procedure to copy the contents of a table into another one. I'm using the package DBMS_SQL to execute a

'CREATE TABLE START_TableName AS (SELECT * FROM TableName)'

At runtime, I receive 'ORA-01031: insufficient privileges'. But if I just type the DDL from SQL Plus, my table is sucessfully created.

Does anyone have an explanation ?
How Can I solve this ?

Many thanks in advance.

Lalaina

PS: FIY find the source code of the proc.

CREATE OR REPLACE PROCEDURE COPY_TABLE (ivTableName	IN 	VARCHAR2 ,
	ovErrorMsg	OUT     VARCHAR2)

IS
vSQL 		VARCHAR2(2048)  ;
iCursor		INTEGER ;
nRowCount	NUMBER  ;

BEGIN iCursor := DBMS_SQL.OPEN_CURSOR ;

vSQL := NULL ;
vSQL := CONCAT(vSQL, 'CREATE TABLE ') ;
vSQL := CONCAT(vSQL, 'START_' ||ivTableName) ;
vSQL := CONCAT(vSQL, ' AS ( SELECT * FROM ' ||ivTableName) ;
vSQL := CONCAT(vSQL, ' )') ;

DBMS_OUTPUT.PUT_LINE(vSQL) ; DBMS_SQL.PARSE(iCursor, vSQL, DBMS_SQL.NATIVE) ; nRowCount := DBMS_SQL.EXECUTE(iCursor) ; DBMS_SQL.CLOSE_CURSOR(iCursor) ; ovErrorMsg := 'Table ' ||ivTableName || ' has been successfully copied into ' ; ovErrorMsg := CONCAT(ovErrorMsg, 'START_' ||ivTableName) ;

EXCEPTION
 WHEN OTHERS THEN
 ovErrorMsg := SQLERRM ;
END COPY_TABLE ;
/

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Oct 20 1998 - 09:12:02 CDT

Original text of this message

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