Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 7ABD3475A27 for ; Tue, 28 May 2002 10:43:04 -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 1B7F2475E28 for ; Tue, 28 May 2002 10:43:01 -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 QAA01435 for ; Tue, 28 May 2002 16:43:04 +0200 (MET DST) Received: by sirari.TechFak.Uni-Bielefeld.DE (SMI-8.6/pk19971205) id QAA17841; Tue, 28 May 2002 16:43:03 +0200 From: "Michael Beckstette" Message-Id: <1020528164303.ZM17839@sirari.TechFak.Uni-Bielefeld.DE> Date: Tue, 28 May 2002 16:43:03 +0200 X-Mailer: Z-Mail (4.0.1 13Jan97) To: pgsql-sql@postgresql.org Subject: dynamic table names, determined by calling parameter MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200205/294 X-Sequence-Number: 7929 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