Executing Dynamic DDL - Mailing list pgsql-general

From Samer Abukhait
Subject Executing Dynamic DDL
Date
Msg-id 7d215b0c05051800074a931481@mail.gmail.com
Whole thread Raw
Responses Re: Executing Dynamic DDL
List 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;

pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: regarding IN clause
Next
From: Richard Huxton
Date:
Subject: Re: Logs