Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 8031C47597A for ; Tue, 28 May 2002 11:53:39 -0400 (EDT) Received: from gemma.TechFak.Uni-Bielefeld.DE (gemma.TechFak.Uni-Bielefeld.DE [129.70.136.103]) by postgresql.org (Postfix) with ESMTP id A34F5475964 for ; Tue, 28 May 2002 11:53:37 -0400 (EDT) Received: from sirari.TechFak.Uni-Bielefeld.DE (sirari.TechFak.Uni-Bielefeld.DE [129.70.132.38]) by gemma.TechFak.Uni-Bielefeld.DE (8.9.1/8.9.1/TechFak/pk+ro20010720) with SMTP id RAA04167 for ; Tue, 28 May 2002 17:53:42 +0200 (MET DST) Received: by sirari.TechFak.Uni-Bielefeld.DE (SMI-8.6/pk19971205) id RAA17961; Tue, 28 May 2002 17:53:41 +0200 From: "Michael Beckstette" Message-Id: <1020528175341.ZM17959@sirari.TechFak.Uni-Bielefeld.DE> Date: Tue, 28 May 2002 17:53:41 +0200 X-Mailer: Z-Mail (4.0.1 13Jan97) To: pgsql-sql@postgresql.org Subject: Creation of a table with dynamic name from inside a pgpsql function MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200205/295 X-Sequence-Number: 7930 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