Re: Default value if query returns 0 rows?

Поиск
Список
Период
Сортировка
От Csaba Nagy
Тема Re: Default value if query returns 0 rows?
Дата
Msg-id 1095438153.3661.33.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Re: Default value if query returns 0 rows?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: psql + autocommit
Следующее
От: John Sidney-Woollett
Дата:
Сообщение: Re: psql + autocommit