Home » SQL & PL/SQL » SQL & PL/SQL » Problem while creating SEQUENCE from PL/SQL
Problem while creating SEQUENCE from PL/SQL [message #39707] Fri, 02 August 2002 13:52 Go to next message
Swamy
Messages: 78
Registered: June 2002
Member
I wrote a procedure as shown below.

CREATE OR REPLACE PROCEDURE refresh_sequence (schema_name IN VARCHAR2, sequence_name IN VARCHAR2)
IS
sql_stmt VARCHAR2(200);
BEGIN
sql_stmt := 'DROP SEQUENCE ' ||schema_name
|| '.' || sequence_name;
EXECUTE IMMEDIATE sql_stmt;
sql_stmt := 'CREATE SEQUENCE ' ||schema_name || '.' || sequence_name || 'INCREMENT BY 1 START WITH 1 MINVALUE 1';
EXECUTE IMMEDIATE sql_stmt;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20000, 'Exception Raised: ' || SQLCODE || ' - ' ||SQLERRM);
END;

I am trying to drop the existing SEQUENCE and then to create the same for getting start values. The procedure is successfully droping the sequence, but giving errors to create. It is giving the following error:

ERROR at line 1:
ORA-20000: Exception Raised: -933 - ORA-00933: SQL command not properly ended
ORA-06512: at "EPHRADEV.REFRESH_SEQUENCE", line 12
ORA-06512: at line 1

Can any one help me what I am doing wrong. I appreciate in advance for your help.

Is there any other solution to refresh a sequence programmatically.
Re: Problem while creating SEQUENCE from PL/SQL [message #39708 is a reply to message #39707] Fri, 02 August 2002 13:58 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You are missing a space before the INCREMENT keyword.

sequence_name || ' INCREMENT


Actually, instead of dropping and recreating the sequence, here is a method for resetting it.

http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:951269671592
Re: Problem while creating SEQUENCE from PL/SQL [message #39710 is a reply to message #39707] Sat, 03 August 2002 02:04 Go to previous message
Swamy
Messages: 78
Registered: June 2002
Member
Thanks Todd for your valuble info.
Previous Topic: Dynamic Variables
Next Topic: How do i get n'th greatest salary from EMP table
Goto Forum:
  


Current Time: Fri Apr 19 08:16:34 CDT 2024