pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PL/PgSQL: selects into strings
2+ messages / 2 participants
[nested] [flat]

* PL/PgSQL: selects into strings
@ 1999-12-02 15:16 Virgilio Sanz <vsanz@el-mundo.net>
  1999-12-03 10:01 ` Re: [SQL] PL/PgSQL: selects into strings Jan Wieck <wieck@debis.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Virgilio Sanz @ 1999-12-02 15:16 UTC (permalink / raw)
  To: 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@el-mundo.net virgilio.sanz@el-mundo.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.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] PL/PgSQL: selects into strings
  1999-12-02 15:16 PL/PgSQL: selects into strings Virgilio Sanz <vsanz@el-mundo.net>
@ 1999-12-03 10:01 ` Jan Wieck <wieck@debis.com>
  0 siblings, 0 replies; 2+ messages in thread

From: wieck@debis.com @ 1999-12-03 10:01 UTC (permalink / raw)
  To: vsanz@el-mundo.net; +Cc: 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 =3D ''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';

    PL/pgSQL  doesn't  support  it. Could get implemented, in the
    mean time look at PL/Tcl, it can do it already.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1999-12-03 10:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-02 15:16 PL/PgSQL: selects into strings Virgilio Sanz <vsanz@el-mundo.net>
1999-12-03 10:01 ` Jan Wieck <wieck@debis.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox