pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
dynamic table names, determined by calling parameter
2+ messages / 1 participants
[nested] [flat]

* dynamic table names, determined by calling parameter
@ 2002-05-27 16:07  Michael Beckstette <mbeckste@TechFak.Uni-Bielefeld.DE>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Beckstette @ 2002-05-27 16:07 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* dynamic table names, determined by calling parameter
@ 2002-05-28 14:43  Michael Beckstette <mbeckste@TechFak.Uni-Bielefeld.DE>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Beckstette @ 2002-05-28 14:43 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-05-28 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-27 16:07 dynamic table names, determined by calling parameter Michael Beckstette <mbeckste@TechFak.Uni-Bielefeld.DE>
2002-05-28 14:43 dynamic table names, determined by calling parameter Michael Beckstette <mbeckste@TechFak.Uni-Bielefeld.DE>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox