Re: functions with plpgsql

Поиск
Список
Период
Сортировка
От Brad Bulger
Тема Re: functions with plpgsql
Дата
Msg-id 3F35CFBD.6070607@potatoe.com
обсуждение исходный текст
Ответ на Re: functions with plpgsql  ("Bernd Hoffmann" <info@unixserver.info>)
Список pgsql-php

Bernd Hoffmann wrote:

> Hallo Andy,
>
>
>>I do not think you can evaluate a declared vairable as a table name in the
>>SELECT statement.
>
>
> where can I find some docu about declare a table by variable.

you need to do this as a dynamic query.

look in the pl/pgsql docs here
http://www.postgresql.org/docs/7.3/interactive/plpgsql-statements.html
and here
http://www.postgresql.org/docs/7.3/interactive/plpgsql-control-structures.html
for description of the FOR-IN-EXECUTE loop you need for dynamic SELECTs

basically it'll be something like

FOR myrecordvar IN EXECUTE ''select max(id) from '' ||
quote_ident(mytablenamevar) LOOP
    ... do some stuff ...
END LOOP;



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

Предыдущее
От: "Bernd Hoffmann"
Дата:
Сообщение: Re: functions with plpgsql
Следующее
От: Ângelo Marcos Rigo
Дата:
Сообщение: Re: Paging results