From: | "Michael Beckstette" <mbeckste(at)TechFak(dot)Uni-Bielefeld(dot)DE> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | dynamic table names, determined by calling parameter |
Date: | 2002-05-28 14:43:03 |
Message-ID: | 1020528164303.ZM17839@sirari.TechFak.Uni-Bielefeld.DE |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
sorry, when this is a silly question, but i wonder why the following pl/pgsql
functions works:
CREATE FUNCTION test (text) RETURNS TEXT AS '
DECLARE
table_name ALIAS FOR $1;
BEGIN
-- test_table is an existing table
CREATE TEMPORARY TABLE temp1 AS SELECT * FROM test_table WHERE (hsp_rank=1 AND
hsp_evalue<=evalue_cutoff);
RETURN table_name;
END;
' LANGUAGE 'plpgsql';
and this one with the table name specified by the calling parameter not:
CREATE FUNCTION test (text) RETURNS TEXT AS '
DECLARE
table_name ALIAS FOR $1;
BEGIN
CREATE TEMPORARY TABLE temp1 AS SELECT * FROM table_name WHERE (hsp_rank=1 AND
hsp_evalue<=evalue_cutoff);
RETURN table_name;
END;
' LANGUAGE 'plpgsql';
Result:
prod2_db=#SELECT test('test_table');
ERROR: parser: parse error at or near "$1"
Any idea ?
Regards
Michael Beckstette
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Beckstette | 2002-05-28 15:53:41 | Creation of a table with dynamic name from inside a pgpsql function |
Previous Message | Tom Lane | 2002-05-28 14:38:06 | Re: Some additional PostgreSQL questions |