Received: from mail2.rdc2.bc.home.com (mail2.rdc2.bc.home.com [24.2.10.85]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f244UDx76931 for ; Sat, 3 Mar 2001 23:30:14 -0500 (EST) (envelope-from pozix@home.com) Received: from elrond.home.com ([24.113.128.171]) by mail2.rdc2.bc.home.com (InterMail vM.4.01.03.00 201-229-121) with ESMTP id <20010304043005.PKXV585.mail2.rdc2.bc.home.com@elrond.home.com>; Sat, 3 Mar 2001 20:30:05 -0800 Message-Id: <5.0.2.1.0.20010303202117.02a09d50@mail.rchmd1.bc.wave.home.com> X-Sender: pozix@mail.rchmd1.bc.wave.home.com X-Mailer: QUALCOMM Windows Eudora Version 5.0.2 Date: Sat, 03 Mar 2001 20:32:37 -0800 To: pgsql-sql@postgresql.org From: Gerald Gutierrez Subject: Passing table names to PL/PGSQL for SELECT/UPDATE/INSERT Cc: Richard Huxton Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Archive-Number: 200103/40 X-Sequence-Number: 1685 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?