Re: Providing an alternative result when there is no result - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Providing an alternative result when there is no result
Date
Msg-id 20090518193656.GD7741@svana.org
Whole thread Raw
In response to Providing an alternative result when there is no result  (Joshua Berry <yoberi@gmail.com>)
List pgsql-general
On Mon, May 18, 2009 at 03:13:56PM -0400, Joshua Berry wrote:
> Hello all,
>
> Is there an easy and efficient way to return a boolean false for a query
> that returns no result, and true for one that does return a result?
>
> Currently we select the result into a temp table.
>
> SELECT INTO temp_table id FROM ... ;

What might work is:

SELECT EXISTS(subquery);

As in:

SELECT EXISTS( SELECT 1 WHERE true );

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Providing an alternative result when there is no result
Next
From: David Wilson
Date:
Subject: Re: Providing an alternative result when there is no result