Search Postgresql Archives

Re: table name as variable within Function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 07, 2005 at 12:22:38PM -0600, Clark Allan wrote:
> 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';

See "Executing Dynamic Commands" in the PL/pgSQL documentation:

http://www.postgresql.org/docs/8.0/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux