Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Alter table then Update in PL/SQL block

496872Oct 27 2009 — edited Oct 27 2009
I am trying to alter the table then update it :

declare

colCount number;*

begin*


select count(*) into colCount from all_tab_cols where table_name = 'TEST' and owner = 'TEST_OWNER';*

dbms_output.put_line('No of Columns in the table : ' || colCount);*


if colCount = 2 then*


dbms_output.put_line('Table needs upgrade');*

execute immediate('ALTER TABLE TEST ADD COL1 VARCHAR2(100) NULL');*

UPDATE TEST SET COL1 = '123';*
commit;*
else*

dbms_output.put_line('No Changes Required');*

end if;*

end;*
Oracle complains that "COL1" is an invalid identifier.

I also tried substitute the UPDATE statement with

** execute immediate('UPDATE TEST SET VCHCHARSET_OUT='UTF8' WHERE VCHCHARSETNAME='UTF8'');**

and there is something wrong with the construction of an Update statement in the parenthesis.

Am I taking the right approach and just need to figuire out the syntax of single quotes or something else is wrong?

thanks in advance.
This post has been answered by thomaso on Oct 27 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2009
Added on Oct 27 2009
6 comments
4,815 views