Executing Dynamic DDL

From: Samer Abukhait <abukhait(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Executing Dynamic DDL
Date: 2005-05-18 07:07:55
Message-ID: 7d215b0c05051800074a931481@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Margus Roo 2005-05-18 08:35:47 postgres 7.4 array count
Previous Message Jan Sunavec 2005-05-18 07:07:13 Count and Results together