Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using IF statements in Oracle
You are trying to do DDL in PL/SQL. Rather than go into details as to how to
do this, I must ask why you think you need to do this...
"KPK" <kpkeller_at_linuxmail.org> wrote in message
news:6f5ea0d.0309120714.13f7afc9_at_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:33:14 CDT
![]() |
![]() |