Re: Passing a table as parameter

Поиск
Список
Период
Сортировка
От Vibhor Kumar
Тема Re: Passing a table as parameter
Дата
Msg-id 07C7753E-AAA7-4F96-BEC0-91FB738F261F@enterprisedb.com
обсуждение исходный текст
Ответ на Passing a table as parameter  (Jon Smark <jon.smark@yahoo.com>)
Ответы Re: Passing a table as parameter  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
On Mar 21, 2011, at 11:13 PM, Jon Smark wrote:

>
> Is there any way for a SQL or PL/pgSQL function to receive a table
> as parameter?  As an illustration, consider the dummy example below.
> Note that functions get_from_data1 and get_from_data2 follow essentially
> the same pattern; it would be nice to define instead a single polymorphic
> function parameterised on the id and table.  Is this possible?


Try Something like given below:
CREATE OR REPLACE FUNCTION tab_pass(text) returns setof numeric
as
$$
   DECLARE
     rec record;
   BEGIN
      for rec in execute 'select empno from '||$1||' where id = 1'
      LOOP
          return next rec.empno;
      END LOOP;
      return next rec.empno;
   END;
$$ language plpgsql;


Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com


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

Предыдущее
От: Vick Khera
Дата:
Сообщение: Re: postgres conferences missing videos?
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Passing a table as parameter