Re: table name as variable within Function

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: table name as variable within Function
Дата
Msg-id 20050707204109.GA26949@winnie.fuhr.org
обсуждение исходный текст
Ответ на table name as variable within Function  (Clark Allan <clarka@gmail.com>)
Список pgsql-general
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/

В списке pgsql-general по дате отправления:

Предыдущее
От: BigSmoke
Дата:
Сообщение: A trigger that acts on a column with a given column name
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: find objects under a specific tablespace