Re: How can I create null value from function call with no results?

From: Seref Arikan <serefarikan(at)gmail(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: How can I create null value from function call with no results?
Date: 2014-07-30 19:08:08
Message-ID: CA+4ThdrghtXyxk=yCcUCGxA97dESrePU4FDrC0puk3Vu9q4O+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi David,
Thanks for the feedback. I've actually tried to do what you've suggested,
but I always found myself unable to do the check for empty result for query
in an elegant way.
That is, I end up thinking about creating a temp table to put the query
results in (which can be > 1), then check if the temp table is empty and
return Null if that is the case.

Your response reads as if there is a more elegant way of doing this, could
you write down a dummy version of the alternative to return query you're
suggesting?

Kind regards
Seref

Ps: sorry for the double post David

On Wed, Jul 30, 2014 at 7:26 PM, David G Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> Seref Arikan wrote
> > select 1,test_empty_row(1);
>
> SELECT 1, (SELECT test_empty_row(1)) AS func_result
>
> You can also adjust the function to either return the result of the query
> OR
> "RETURN NULL" if no results were found. i.e., do not use "RETURN QUERY"
>
> David J.
>
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/How-can-I-create-null-value-from-function-call-with-no-results-tp5813311p5813313.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Seref Arikan 2014-07-30 19:20:39 Re: How can I create null value from function call with no results?
Previous Message Scott Marlowe 2014-07-30 19:07:12 Re: free RAM not being used for page cache