table name as variable within Function

From: Clark Allan <clarka(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: table name as variable within Function
Date: 2005-07-07 18:22:38
Message-ID: 4a7a732105070711222daafaf4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here is an example of what i would like to do...
---------------------------------------
CREATE FUNCTION fun_totalrecords(varchar) RETURNS int8 AS'
DECLARE
theTable ALIAS FOR $1;
result int := 0;
BEGIN
result = COUNT(*) FROM theTable; -- this is where i need help
RETURN result;

END; 'LANGUAGE 'plpgsql';
---------------------------------------
Thanks for the help....
Clark

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ying Lu 2005-07-07 18:35:47 find objects under a specific tablespace
Previous Message Christopher Browne 2005-07-07 17:10:07 Re: How to force Postgres to calculate MAX(boolean)