Re: [GENERAL] Providing an alternative result when there is no result

2009-05-20 Thread Merlin Moncure
On Tue, May 19, 2009 at 7:00 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: On Mon, May 18, 2009 at 3:13 PM, Joshua Berry yob...@gmail.com wrote: Is there an easy and efficient way to return a boolean false for a query that returns no result, and true for one

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-19 Thread David Fetter
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

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-19 Thread Merlin Moncure
On Mon, May 18, 2009 at 3:13 PM, Joshua Berry yob...@gmail.com 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 (

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-19 Thread Tom Lane
Merlin Moncure mmonc...@gmail.com writes: On Mon, May 18, 2009 at 3:13 PM, Joshua Berry yob...@gmail.com 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

[GENERAL] Providing an alternative result when there is no result

2009-05-18 Thread Joshua Berry
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

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-18 Thread Pavel Stehule
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 yob...@gmail.com: Hello all, Is there an easy and

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-18 Thread Martijn van Oosterhout
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

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-18 Thread David Wilson
On Mon, May 18, 2009 at 3:13 PM, Joshua Berry yob...@gmail.com 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

Re: [GENERAL] Providing an alternative result when there is no result

2009-05-18 Thread Reece Hart
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 *