Executing Dynamic DDL

Поиск
Список
Период
Сортировка
От Samer Abukhait
Тема Executing Dynamic DDL
Дата
Msg-id 7d215b0c05051800074a931481@mail.gmail.com
обсуждение исходный текст
Ответы Re: Executing Dynamic DDL  (Michael Fuhr <mike@fuhr.org>)
Список 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 по дате отправления:

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: regarding IN clause
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Logs