On Tue, May 19, 2009 at 7:00 PM, Tom Lane wrote:
> Merlin Moncure writes:
>> On Mon, May 18, 2009 at 3:13 PM, Joshua Berry wrote:
>>> 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?
>
>> Probably the
Merlin Moncure writes:
> On Mon, May 18, 2009 at 3:13 PM, Joshua Berry wrote:
>> 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?
> Probably the best general approach is to:
> select count(*) = 1 from
On Mon, May 18, 2009 at 3:13 PM, 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?
>
Probably the best general approach is to:
select count(*) = 1 from
(
limit 1
)
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_t
On Mon, 2009-05-18 at 15:13 -0400, Joshua Berry wrote:
> 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?
Presuming that you're not using the values in temp_table, I think you
should be using PERFORM
On Mon, May 18, 2009 at 3:13 PM, Joshua Berry wrote:
> Any hints/tips? Is our original solution okay, or is there something we can
> do to improve things?
It seems as if you don't really care about the results of the query-
just whether or not it returns any rows. In that case, why not
something
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_t
Hello
look on GET DIAGNOSTIC statement or FOUND variable
CREATE OR REPLACE FUNCTION foo()
RETURNS boolean AS $$
BEGIN
SELECT INTO temp_table ...
RETURN found;
END;
$$ language plpgsql;
regards
Pavel Stehule
2009/5/18 Joshua Berry :
> Hello all,
>
> Is there an easy and efficient way to retu
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 ... ;
IF temp_table IS NULL THEN
resp:= 'NO';
ELSE
resp:=