PLPGSQL

From: "Oberpriller, Wade D(dot)" <oberpwd(at)nsc-msg01(dot)network(dot)com>
To: "PostgreSQL General Help (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: PLPGSQL
Date: 2001-03-01 20:02:30
Message-ID: A7E1C26945C8D211ADBF0008C709661A01D4110B@nsc-msg02.network.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

Is there a way to do variable interpolation in the SQL statements in
PLPGSQL? For example
suppose I wanted to write a generic routine that will search a given table
by its "id" field
like so:

CREATE FUNCTION search_by_id (TEXT, TEXT)
RETURNS RECORD
AS
'DECLARE rec RECORD;
BEGIN
SELECT INTO rec * FROM $1 WHERE id = $2;
RETURN rec;
END;'
LANGUAGE 'PLPGSQL';

Is this possible?

Sincerely,

Wade D. Oberpriller
StorageTek
612-424-1538

Browse pgsql-general by date

  From Date Subject
Next Message Martin A. Marques 2001-03-01 20:08:32 user/group creation privileges
Previous Message Richard Huxton 2001-03-01 20:01:53 Re: something more about my question about performance