function with tablename parameter

From: Miso Hlavac <hlavki(at)medium13(dot)sk>
To: pgsql-general(at)postgresql(dot)org
Subject: function with tablename parameter
Date: 2003-10-27 11:28:32
Message-ID: 835065354.20031027122832@medium13.sk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hello,

it is possible to write something similar???

create function get_count(varchar(32)) RETURNS int4 AS '
DECLARE
tmp int4;
BEGIN
SELECT COUNT(*) INTO tmp FROM $1;
RETURN tmp;
END;' LANGUAGE 'plpgsql';

SELECT get_count('k_part');
SQL error:
ERROR: parser: parse error at or near "$1" at character 24

thanx, miso

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben-Nes Michael 2003-10-27 11:38:04 Re: Recomended FS
Previous Message Neil Zanella 2003-10-27 09:40:53 Re: incrementing and decrementing dates by day increments programmatically