Alter table then Update in PL/SQL block
496872Oct 27 2009 — edited Oct 27 2009I 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.