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 -> Re: why cant i do this?? any clues on how i should go about

Re: why cant i do this?? any clues on how i should go about

From: Vinay Bhushan <bhushanvinay_at_gmail.com>
Date: 8 Aug 2006 10:29:03 -0700
Message-ID: <1155058143.135170.231620@i3g2000cwc.googlegroups.com>


Thanks for the reply,

but what do you propose me to do insted of using a Execute immidiate;

i would like to create the col if not existing;

how would i achive it.

Regards
Vinay
Sybrand Bakker wrote:

> On 8 Aug 2006 09:42:30 -0700, "Vinay Bhushan" <bhushanvinay_at_gmail.com>
> wrote:
>
> >DECLARE
> > v_userTabColumns INT;
> >BEGIN
> >
> > SELECT COUNT(*) INTO v_userTabColumns
> > FROM USER_TAB_COLUMNS
> > WHERE TABLE_NAME ='T'
> > AND COLUMN_NAME ='ABCD';
> >
> > IF v_userTabColumns >0 THEN
> > DBMS_OUTPUT.PUT_LINE ('<<ABCD>><<T>> already Exists');
> > ELSE
> > ALTER TABLE T ADD (ABCD VARCHAR2(50));
> > DBMS_OUTPUT.PUT_LINE ('New column <<ABCD>> for <<t>>
> >created.');
> > END IF;
> >
> >
> >
> >END;
>
> ALTER TABLE is a DDL statement. DDL statements need e
> EXECUTE IMMEDIATE '<statement>'
>
> However, IMO, ALTERing a table in PL/SQL is a *VERY BAD IDEA*.
>
> --
> Sybrand Bakker, Senior Oracle DBA
Received on Tue Aug 08 2006 - 12:29:03 CDT

Original text of this message

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