Re: Compile query results into a table

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Compile query results into a table
Дата
Msg-id CAKFQuwb-dpROZB=w4Fuq0TC0w05_uVex9f28EMjTsdpaZumiQg@mail.gmail.com
обсуждение исходный текст
Ответ на Compile query results into a table  (Santosh Udupi <email@hitha.net>)
Список pgsql-admin
On Thu, Jan 16, 2020 at 4:22 PM Santosh Udupi <email@hitha.net> wrote:


Sample calls to the function:

 // select * from dbo. test  ('search_in_authors')

// select * from dbo. test ('search_in_authors, search_in_editors')

// select * from dbo. test ('search_in_authors, search_in_editors,search_in_publishers ')

-----------------------------------------------------

 Are there any options in PostgreSQL to achieve this other than using a temp table ?

Since the names of the tables are dynamic you would need to use pl/pgsql and its EXECUTE capability and build up a useful SQL command on-the-fly.  To avoid using temporary tables you would need to put all the separate queries into the same main query.  This can be done with "UNION" and/(or?) Common Table Expressions (CTE - the WITH clause).

David J.

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

Предыдущее
От: Santosh Udupi
Дата:
Сообщение: Compile query results into a table
Следующее
От: Ken Benson
Дата:
Сообщение: delete then insert