Thread: PLPGSQL

PLPGSQL

From
"Oberpriller, Wade D."
Date:
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

Re: PLPGSQL

From
Olleg Samojlov
Date:
Look docs "CREATE LANGUAGE".

Dagoberto wrote:
> I want to know if I can add Pl/PgSQL support to my databases with an
> internal command not an external one(createlang).

--
Olleg Samojlov