Re: Coditional join of query using PostgreSQL

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Nick Dro <postgresql(at)walla(dot)co(dot)il>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Coditional join of query using PostgreSQL
Date: 2017-05-15 17:26:22
Message-ID: CAKFQuwa4QJNQFcC7GHREA8aKM7sFHUZMnrfcBtROCkt0229+mw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, May 15, 2017 at 10:02 AM, Nick Dro <postgresql(at)walla(dot)co(dot)il> wrote:

> Hi,
> I'm new to postgresql and couldn't find answer to this situation anywhere.
> I asked this here:
> http://stackoverflow.com/questions/43984208/coditional-
> join-of-query-using-postgresql
>
> I hope there is a better solution rather than creating two separated
> functions :(
>

​Generate the SQL itself in a string then execute the string. Its called
"Dynamic SQL"​.

https://www.postgresql.org/docs/9.6/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jack 2017-05-15 17:41:15 Re: Coditional join of query using PostgreSQL
Previous Message Ronny Abraham 2017-05-15 17:25:30 Re: Insert performance and disk usage in JSON vs JSONB