Re: EXECUTE IMMEDIATE help

From: FaheemRao <faheemrao_at_yahoo.com>
Date: 16 Dec 2003 10:58:07 -0800
Message-ID: <43b58913.0312161058.75727e13_at_posting.google.com>


you would like to include brackets in the statement as well like this

EXECUTE IMMEDIATE ('ALTER TABLE owner.table_name

        ADD (column_name CHAR(1) DEFAULT '' '' NOT NULL)');

Thanks

Faheem

finlaymark_at_hotmail.com (finlma) wrote in message news:<8b454add.0312150935.75598e78_at_posting.google.com>...
> I'm trying to run an EXECUTE IMMEDIATE within a PL/SQL if loop but it
> doesn't work for me. I'm trying to create a column conditionally but
> it doesn't work. It fails because there are apostrophes within the
> statement. How do I override the apostrophe?
>
> DECLARE cCount NUMBER;
> BEGIN SELECT count(*)
> INTO cCount
> FROM all_tab_columns
> WHERE owner = 'Owner'
> AND table_name = 'table_name'
> AND column_name = 'column_name' ;
>
> IF cCount = 0 THEN
> EXECUTE IMMEDIATE 'ALTER TABLE owner.table_name
> ADD (column_name CHAR(1) DEFAULT ' ' NOT NULL)';
> ELSE
> EXECUTE IMMEDIATE 'ALTER TABLE owner.table_name
> MODIFY column_name DEFAULT ' '';
> END IF;
> END;
>
> Thanks
Received on Tue Dec 16 2003 - 19:58:07 CET

Original text of this message