DDL using PL/SQL [message #39740] |
Tue, 06 August 2002 15:30 |
IndyWest
Messages: 6 Registered: July 2002
|
Junior Member |
|
|
Howdy folks,
I have ended up with an Insufficient Privileges problem while using DDL in my PL/SQL routine. The purpose is to drop and create a sequence again. While Oracle goes through the Drop correctly, it fails on the Create with an "ORA-01031: insufficient privileges" option. The current user falls under the dba role. Here's the code:
=====
i:= DBMS_SQL.Open_Cursor;
strSQL:= 'Drop Sequence My_Seq';
DBMS_SQL.Parse(i, strSQL, DBMS_SQL.NATIVE);
j:= DBMS_SQL.Execute(i);
DBMS_SQL.Close_Cursor(i);
i:= DBMS_SQL.Open_Cursor;
strSQL:= 'Create Sequence My_Seq Increment By 1 Start With 1 MinValue 1 MaxValue 99999999 NoCycle NoOrder NoCache';
DBMS_SQL.Parse(i, strSQL, DBMS_SQL.NATIVE);
j:= DBMS_SQL.Execute(i);
DBMS_SQL.Close_Cursor(i);
========
It fails on the second execute statement with the message. I was able to execute both of these successfully outside the program. Any pointers? Or is there a better method?
Thanks a bunch.
|
|
|
Re: DDL using PL/SQL [message #39744 is a reply to message #39740] |
Tue, 06 August 2002 21:43 |
Rajarshi
Messages: 11 Registered: November 2001
|
Junior Member |
|
|
Use the package DBMS_DDL instead of DBMS_SQL.... or use "EXECUTE IMMEDIATE" to do the DDL job. DBMS_SQL works file with SELECs and DMLs but notwith DDLs.
|
|
|
|
Re: DDL using PL/SQL [message #39762 is a reply to message #39740] |
Wed, 07 August 2002 14:52 |
IndyWest
Messages: 6 Registered: July 2002
|
Junior Member |
|
|
Thanks Mahesh and Rajarshi. Actually I don't use Ora 8i so perhaps Execute Immediate isn't one of the options. DBMS_DDL is one I should try out though.
However, I did find another link in OraFaq which actually suited by needs much much better! I used Alter Sequence with a negative increment and it works as a charm!
Thanks all the same!
|
|
|