Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Using IF statements in Oracle
Hello: I am trying to write a script that will alter some schema in
an Oracle 9i database. The following is a sample of my script:
declare lngNumItems number(7,0);
begin
lngNumItems := 0; Select count(*) into lngNumItems from gasanalysistb; if (lngNumItems > 0) then alter table gasanalysistb add mycol number(3,0) default 100; commit work; end if;
Oracle gives me the following error when I run this:
declare lngNumItems number(7,0);
begin
lngNumItems := 0; Select count(*) into lngNumItems from gasanalysistb; if (lngNumItems > 0) then alter table gasanalysistb add mycol number(3,0) default 100; commit work; end if;
ORA-06550: line 8, column 4: 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
<a single-quoted SQL string> pipe
What am I doing wrong? Received on Fri Sep 12 2003 - 10:14:53 CDT