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 -> Using IF statements in Oracle

Using IF statements in Oracle

From: KPK <kpkeller_at_linuxmail.org>
Date: 12 Sep 2003 08:14:53 -0700
Message-ID: <6f5ea0d.0309120714.13f7afc9@posting.google.com>


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;	 	

end;

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;

end;
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

Original text of this message

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