From: | "Michael Beckstette" <mbeckste(at)TechFak(dot)Uni-Bielefeld(dot)DE> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Creation of a table with dynamic name from inside a pgpsql function |
Date: | 2002-05-28 15:53:41 |
Message-ID: | 1020528175341.ZM17959@sirari.TechFak.Uni-Bielefeld.DE |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
i have tried to create a table with a name specified by a calling parameter of
a pgsql function. Something like this:
CREATE FUNCTION test (varchar) RETURNS TEXT AS '
DECLARE
table_name ALIAS FOR $1;
query_string varchar;
BEGIN
query_string:= ''CREATE TABLE temp1 AS SELECT * FROM ''||
quote_ident(table_name) || '' WHERE (hsp_rank=1 AND hsp_evalue<=0.001)'';
RAISE NOTICE ''Query: %'',query_string;
EXECUTE query_string;
RETURN table_name;
END;
' LANGUAGE 'plpgsql';
with the following result:
prod2_db=# select test('blasthits_obj_174_q122_db123');
NOTICE: Query: CREATE TABLE temp1 AS SELECT * FROM
blasthits_obj_174_q122_db123 WHERE (hsp_rank=1 AND hsp_evalue<=0.001)
ERROR: EXECUTE of SELECT ... INTO is not implemented yet
prod2_db=#
i read in the docs, that an SELECT INTO is not fully supported, but how can i
solve this problem ? Any idea or workaround ?
Regards
Michael Beckstette
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Eckermann | 2002-05-28 17:04:07 | Re: Functions with dynamic queries |
Previous Message | Michael Beckstette | 2002-05-28 14:43:03 | dynamic table names, determined by calling parameter |