Re: Can I trigger an action from a coalesce ?

Поиск
Список
Период
Сортировка
От Christophe Pettus
Тема Re: Can I trigger an action from a coalesce ?
Дата
Msg-id 982511F6-2957-43EE-8A28-3A5541B56ADF@thebuild.com
обсуждение исходный текст
Ответ на Re: Can I trigger an action from a coalesce ?  (stan <stanb@panix.com>)
Ответы Re: Can I trigger an action from a coalesce ?
Список pgsql-general

> On Feb 22, 2020, at 13:33, stan <stanb@panix.com> wrote:
> I suppose you are suggesting that the function try the original SELECT, and
> if it returns a NULL then retun the default AND do the raise NOTICE?

Something like this:

create function supply_default() returns int as $$
begin
   raise notice 'Supplied default';
   return 1;
end;
$$ immutable language plpgsql;

xof=# create table t ( i integer default supply_default(), t text );
CREATE TABLE
xof=# insert into t(i, t) values (2, 'text');
INSERT 0 1
xof=# insert into t(t) values ('text');
NOTICE:  Supplied default
INSERT 0 1

--
-- Christophe Pettus
   xof@thebuild.com




В списке pgsql-general по дате отправления:

Предыдущее
От: stan
Дата:
Сообщение: Re: Can I trigger an action from a coalesce ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Can I trigger an action from a coalesce ?