PL/PgSQL: selects into strings

From: Virgilio Sanz <vsanz(at)el-mundo(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: PL/PgSQL: selects into strings
Date: 1999-12-02 15:16:24
Message-ID: 19991202161624.D1959@el-mundo.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi list,

I'm just added to the list and I'm not sure whether the following is a
FAQ or not possible. Anyway, here it goes:

Is there a way to execute a query stored in a string?

I mean, something like:

function test(text) as returns opaque as '
declare
v_weekday alias for $1;
s_qry text;
rec record;
begin
s_qry = ''select field1,field2, '' || v_weekday || '' from t_diary'';
for rec in exec_sql(s_qry)
-- ^ this is what I'm looking for...
-- [do what is needed]
loop
end loop;
end;
' language 'plpgsql';

Thanks in advance,
Virgilio

--
Virgilio Sanz vsanz(at)el-mundo(dot)net virgilio(dot)sanz(at)el-mundo(dot)es
Diario el Mundo en Internet http://www.el-mundo.es

Email me with "send key pub" on subject to get my public key

Kime's Law for the Reward of Meekness:
Turning the other cheek merely ensures two bruised cheeks.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Griffin 1999-12-02 18:09:33 Logical and for int4?
Previous Message Karel Zak - Zakkr 1999-12-02 11:11:56 Re: [SQL] arrays