From: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | dynamic sql in PL-Pgsql ? |
Date: | 2008-09-26 20:19:33 |
Message-ID: | 0836165E8EE50F40A3DD8F0D87137267012158BE@azsmsx421.amr.corp.intel.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi:
I want to do something like this.....
create or replace function foo(varchar, varchar) returns integer as $$
declare
user_attrib alias for $1;
attrib_val alias for $2;
rec record;
begin
for rec in
select name from people_table where user_attrib = attrib_value
loop
insert into my_temp_table (attrib, value, name) values
(user_attrib, attrib_value, rec.name);
end loop;
end;
$$ language plpgsql;
As you can see, the select statement needs to be dynamic in that the
column name is stored in a variable.
Can this be done?
Thanks
-dave
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2008-09-26 20:38:58 | Re: dynamic sql in PL-Pgsql ? |
Previous Message | Decibel! | 2008-09-26 18:45:02 | Is there any way to reliably influence WHERE predicate evaluation ordering? |