PLPGSQL - Mailing list pgsql-general

From Oberpriller, Wade D.
Subject PLPGSQL
Date
Msg-id A7E1C26945C8D211ADBF0008C709661A01D4110B@nsc-msg02.network.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: "Anthony Metzidis"
Date:
Subject: PG_PWD and PG_SHADOW
Next
From: jean-francois butkiewicz
Date:
Subject: Newbie question about locks...