Re: Constructing a SELECT statement in pl/pgsql

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Constructing a SELECT statement in pl/pgsql
Дата
Msg-id 464B87F8.30804@archonet.com
обсуждение исходный текст
Ответ на Constructing a SELECT statement in pl/pgsql  (Robert Fitzpatrick <lists@webtent.net>)
Список pgsql-general
Robert Fitzpatrick wrote:
> I guess my question is how to replace the following...
>
> FOR searchresults IN SELECT * FROM my_view WHERE <snip> LOOP
>
> With something like this...
>
> FOR searchresults IN SELECT DISTINCT clientname FROM my_view WHERE <snip> LOOP

Build the query as text and use EXECUTE (see manuals for details).

You'll also find quote_ident() and quote_literal() useful - again see
manuals.

You'll need to think through the type implications of picking columns
based on supplied parameters - how do you cope with selecting an integer
this time and a text column next time?

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Robert Fitzpatrick
Дата:
Сообщение: Constructing a SELECT statement in pl/pgsql
Следующее
От: Brian Wipf
Дата:
Сообщение: Re: Performance issues of one vs. two split tables.