Re: Default value if query returns 0 rows? - Mailing list pgsql-general

From Csaba Nagy
Subject Re: Default value if query returns 0 rows?
Date
Msg-id 1095438153.3661.33.camel@localhost.localdomain
Whole thread Raw
In response to Re: Default value if query returns 0 rows?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
[snip]
> Another way is a subselect:
>
>     select coalesce((select id from map where name = 'foo'), -1);
Then why not:

select coalesce((select id from map where name = 'foo' limit 1), -1);

This should work even if there are more rows with foo.

>
> but this one will actively blow up if there are multiple 'foo' rows,
> so it doesn't solve that problem either.
>
>             regards, tom lane
>



pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: psql + autocommit
Next
From: John Sidney-Woollett
Date:
Subject: Re: psql + autocommit