From: Richard Huxton <dev@archonet.com>
To: Gerald Gutierrez <pozix@home.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Passing table names to PL/PGSQL for SELECT/UPDATE/INSERT
Date: Sun, 04 Mar 2001 19:27:00 +0000
Message-ID: <3AA29705.B1D291D6@archonet.com> (raw)
References: <5.0.2.1.0.20010303202117.02a09d50@mail.rchmd1.bc.wave.home.com>
Gerald Gutierrez wrote:
>
> I'd like to generalize my function. As per Richard Huxton's suggestion to
> create tables named after session ID (thanks Richard)s, I'd like to pass in
> some table names so that the algorithm can read from and write into tables
> that I specify as parameters to the function. Sometihng like:
Known limitation - sorry, should have made things clear.
> select dijkstra(inputtablename, outputtablename);
>
> I've tried typing the parameters as TEXT, and then just inserting $1 in the
> select (e.g. SELECT * from $1 ...) This doesn't work, nor did a number of
> other ways I tried.
Basically, I can think of 3 solutions. Bear in mind it's late here, I've
had a few drinks with dinner.
1. Use the EXECUTE statement in 7.1 to run the query
2. Use the EXECUTE statement to construct a custom function, one for
each session with the table hard-coded (you could also do this from the
application I'd guess)
3. Try pl/Tcl - I _think_ that lets you construct a dynamic query, but I
don't know TCL so can't say (it's supposed to be easy enough but I've
never got round to it).
HTH
- Richard Huxton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, pozix@home.com
Subject: Re: Passing table names to PL/PGSQL for SELECT/UPDATE/INSERT
In-Reply-To: <3AA29705.B1D291D6@archonet.com>
References: <5.0.2.1.0.20010303202117.02a09d50@mail.rchmd1.bc.wave.home.com> <3AA29705.B1D291D6@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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