Received: from orion.SAPserv.Hamburg.dsh.de (Tpolaris2.sapham.debis.de [53.2.131.8]) by hub.org (8.9.3/8.9.3) with SMTP id FAA49447 for ; Fri, 3 Dec 1999 05:10:01 -0500 (EST) (envelope-from wieck@debis.com) Received: by orion.SAPserv.Hamburg.dsh.de for pgsql-sql@postgreSQL.org id m11tpWo-0003kGC; Fri, 3 Dec 99 11:01 MET Message-Id: From: wieck@debis.com (Jan Wieck) Subject: Re: [SQL] PL/PgSQL: selects into strings To: vsanz@el-mundo.net Date: Fri, 3 Dec 1999 11:01:26 +0100 (MET) Cc: pgsql-sql@postgreSQL.org Reply-To: wieck@debis.com (Jan Wieck) In-Reply-To: <19991202161624.D1959@el-mundo.net> from "Virgilio Sanz" at Dec 2, 99 04:16:24 pm X-Mailer: ELM [version 2.4 PL25] Content-Type: text > 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) #