Home » SQL & PL/SQL » SQL & PL/SQL » what is error in below code?
what is error in below code? [message #582903] Tue, 23 April 2013 05:26 Go to next message
pankajdurve
Messages: 18
Registered: April 2013
Location: MUMBAI
Junior Member
declare
noval exception;
pragma exception_init(noval,-02437);
begin
alter table std modify id number constraint pk_id1 primary key ;

exception
when noval then
dbms_output.put_line('can not add');
end;
/
error
ERROR at line 5:
ORA-06550: line 5, column 1:
PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe

Re: what is error in below code? [message #582905 is a reply to message #582903] Tue, 23 April 2013 05:30 Go to previous messageGo to next message
Michel Cadot
Messages: 58523
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You cannot use DDL directly in PL/SQL, you have to call it through EWXECUTE IMMEDIATE (search for this in PL/SQL User's Guide and Reference).

Regards
Michel
thanks [message #582907 is a reply to message #582905] Tue, 23 April 2013 05:44 Go to previous messageGo to next message
pankajdurve
Messages: 18
Registered: April 2013
Location: MUMBAI
Junior Member
i executed that code very well
declare
noval exception;
pragma exception_init(noval,-02437);
begin
execute immediate 'alter table std modify id number constraint pk_id1 primary key ';
exception
when noval then
dbms_output.put_line('can not add');
end;
/
thanks!!
Re: thanks [message #582915 is a reply to message #582907] Tue, 23 April 2013 06:24 Go to previous message
Michel Cadot
Messages: 58523
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thanks for the feedback.

Before your next question, Please read How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.

Regards
Michel
Previous Topic: How to get the total number of occurrences based on the value of a column.
Next Topic: Handeling special charater '&' in oracle stored procedure
Goto Forum:
  


Current Time: Thu Jul 24 02:27:12 CDT 2014

Total time taken to generate the page: 0.14476 seconds