Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 64109475972 for ; Mon, 27 May 2002 12:07:46 -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 4B6D3475898 for ; Mon, 27 May 2002 12:07:44 -0400 (EDT) Received: from teak.TechFak.Uni-Bielefeld.DE (teak.TechFak.Uni-Bielefeld.DE [129.70.132.10]) by gemma.TechFak.Uni-Bielefeld.DE (8.9.1/8.9.1/TechFak/pk+ro20010720) with ESMTP id SAA27404 for ; Mon, 27 May 2002 18:07:43 +0200 (MET DST) Received: (from mbeckste@localhost) by teak.TechFak.Uni-Bielefeld.DE (8.10.2+Sun/8.9.1) id g4RG7hE18268 for pgsql-sql@postgresql.org; Mon, 27 May 2002 18:07:43 +0200 (MEST) From: "Michael Beckstette" Message-Id: <1020527180743.ZM18265@teak.TechFak.Uni-Bielefeld.DE> Date: Mon, 27 May 2002 18:07:43 +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/285 X-Sequence-Number: 7920 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