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

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: Seref Arikan <serefarikan(at)gmail(dot)com>, 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-31 18:34:29
Message-ID: B6F6FD62F2624C4C9916AC0175D56D8828AC3CEF@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I want to call a function using a column of a table as the parameter and
> return the parameter and function results together.
> The problem is, when the function returns an empty row my select statement
> that uses the function returns an empty row as well.

Hello,
not sure if it makes sense in your context, but something like this could do the job:

WITH SEL AS ( Your Query)
SELECT * FROM SEL
UNION ALL
SELECT 'nothing found' WHERE NOT EXISTS ( select * from sel);

regards,

Marc Mamin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kynn Jones 2014-07-31 18:38:15 How to implement a uniqueness constraint across multiple tables?
Previous Message Bruce Momjian 2014-07-31 15:39:20 Re: Postgress Doubts