EXECUTE IMMEDIATE help
From: finlma <finlaymark_at_hotmail.com>
Date: 15 Dec 2003 09:35:59 -0800
Message-ID: <8b454add.0312150935.75598e78_at_posting.google.com>
Date: 15 Dec 2003 09:35:59 -0800
Message-ID: <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;
IF cCount = 0 THEN
BEGIN SELECT count(*)
INTO cCount
FROM all_tab_columns
WHERE owner = 'Owner'
AND table_name = 'table_name'
AND column_name = 'column_name' ;
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 Mon Dec 15 2003 - 18:35:59 CET