i am trying to execute an 'alter table' statement dynamically.. it
seems that "execute" only works with DML..
is there any way to execute DDL statements??
here is what i am trying to do:
--------------------
create or replace function em.process_table (
p_table varchar)
returns void as $$
declare
v_check bool;
begin
-- Add Creation TimeStamp column if it is not there.
select count (*)
into v_check
from em.all_table_columns
where tablename = p_table
and columnname = 'creation_timestamp';
if v_check then
execute 'alter table em.' || p_table || ' add creation_timestamp
timestamp not null';
end if;
return;
end;$$ language plpgsql;