Search Postgresql Archives

Executing Dynamic DDL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux