Passing table names to PL/PGSQL for SELECT/UPDATE/INSERT

From: Gerald Gutierrez <pozix(at)home(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Richard Huxton <dev(at)archonet(dot)com>
Subject: Passing table names to PL/PGSQL for SELECT/UPDATE/INSERT
Date: 2001-03-04 04:32:37
Message-ID: 5.0.2.1.0.20010303202117.02a09d50@mail.rchmd1.bc.wave.home.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


I've written my Dijkstra's algorithm in PL/PGSQL. It didn't turn out to be
a big deal at all actually, programming-wise. I understand execution speed
will be poor but it shouldn't be any slower than having something else,
like PHP or Java, execute logic and query the database.

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:

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.

How can this be done?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gerald Gutierrez 2001-03-04 04:37:42
Previous Message The Hermit Hacker 2001-03-04 03:05:29 Re: [HACKERS] why the DB file size does not reduce when 'delete'the data in DB?