From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Santosh Udupi <email(at)hitha(dot)net> |
Cc: | Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Compile query results into a table |
Date: | 2020-01-17 00:22:48 |
Message-ID: | CAKFQuwb-dpROZB=w4Fuq0TC0w05_uVex9f28EMjTsdpaZumiQg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Thu, Jan 16, 2020 at 4:22 PM Santosh Udupi <email(at)hitha(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Benson | 2020-01-17 20:03:21 | delete then insert |
Previous Message | Santosh Udupi | 2020-01-16 23:21:40 | Compile query results into a table |