From: David Richter <D.Richter@DKFZ.de>
To: pgsql-sql@postgresql.org
Subject: PL/PGSQL function with parameters
Date: Tue, 30 Jan 2001 13:14:49 +0100
Message-ID: <3A76B039.9A59890@DKFZ-heidelberg.de> (raw)
Folks,
I wrote that function, wich doesn't work. I want to hand over the name
of the tables(relation_table, update_table) and a
column(column_to_fill). The intention is, to use the function also with
other tables(not hard coded).
BUT this error appears :
psql:restructure.sql:32: ERROR: parser: parse error at or near "$1"
I didn't found any solution.
I would be grateful , if I could get some more Examples(more than in the
Docu of www.postgresql.org and Bruce Monjiam's Book) about parameters in
PL/PGSQL - functions.
I would be no less grateful if anybody give detailed suggestions.
CREATE FUNCTION patient_study_restructure (text,text,text) RETURNS
integer AS '
DECLARE
relation_table ALIAS FOR $1;
update_table ALIAS FOR $2;
column_to_fill ALIAS FOR $3;
psr_rec record;
bound integer;
i integer := 0;
BEGIN
FOR psr_rec IN SELECT * FROM relation_table LOOP
UPDATE update_table
SET column_to_fill = psr_rec.parentoid
WHERE chilioid = psr_rec.childoid;
i := i + 1;
END LOOP;
IF NOT FOUND THEN RETURN 1;
ELSE RETURN i;
END IF;
END;
' LANGUAGE 'plpgsql';
SELECT
patient_study_restructure('relpatient_study000','study','patientoid');
Anybody (Jan Wieck?) who can make some sugestions on
the above will
receive my enthusiastic gratitude.
David
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: D.Richter@DKFZ.de
Subject: Re: PL/PGSQL function with parameters
In-Reply-To: <3A76B039.9A59890@DKFZ-heidelberg.de>
References: <3A76B039.9A59890@DKFZ-heidelberg.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox