Search Postgresql Archives

Re: using vars in ddl in procedure call

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

 



Hello,
you need to use execute command 

i.e.
execute 'alter table ........ ' || newcol || ';'

Regards



From: "Gauthier, Dave" <dave.gauthier@xxxxxxxxx>
To: "pgsql-general@xxxxxxxxxxxxxx" <pgsql-general@xxxxxxxxxxxxxx>
Sent: Wednesday, August 29, 2012 4:56 PM
Subject: using vars in ddl in procedure call

Hi:
 
v9.0.1 on linux.
 
Trying (failing) a test to see if I can run ddl in a procedure where elements of the ddl are vars.  Consider...
 
create or replace function newcol (text) returns integer as $$
declare
  newcol alias for $1;
begin
 
  alter table target add column newcol text;
 
return(0);
 
end;
$$ language plpgsql;
 
This successfully adds a column called "newcol" instead of what I passed it as an arg.
 
Any suggestions on how to make this work?
 
Thanks !
 



[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