table name in pl/pgsql - Mailing list pgsql-general

From ON.KG
Subject table name in pl/pgsql
Date
Msg-id 15933163937.20041125194221@on.kg
Whole thread Raw
In response to Re: Benchmark-Comparison PostGreSQL vs. SQL Server  (Richard Huxton <dev@archonet.com>)
Responses Re: table name in pl/pgsql
Re: table name in pl/pgsql
Re: table name in pl/pgsql
List pgsql-general
New question:

i have tables like
table_20041124,
table_20041125,
etc...

i'm trying to make function (for example):
=====================================
CREATE FUNCTION get_count(text, text)
RETURNS int2 AS '
  DECLARE
    cnt int4;
  BEGIN
    SELECT INTO cnt COUNT(*)
    FROM table_$1           -- That doesn't work
    WHERE key = $2;

    RETURN cnt;
  END;'
LANGUAGE 'plpgsql';
=====================================

call this function by:

=====================================
SELECT get_count("20041124", "something");
=====================================

string in funstion -  FROM table_$1

how could i get a final correct table name here?

Thanx!


pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Benchmark-Comparison PostGreSQL vs. SQL Server
Next
From: Julian Legeny
Date:
Subject: VACUUM ANALYZE question - PostgreSQL performance tests