Using Insert - Default in a condition expression ??

Поиск
Список
Период
Сортировка
От Postgres User
Тема Using Insert - Default in a condition expression ??
Дата
Msg-id b88c3460909282325s861cdf2sd907757e4f307b2@mail.gmail.com
обсуждение исходный текст
Ответы Re: Using Insert - Default in a condition expression ??  (Sim Zacks <sim@compulab.co.il>)
Список pgsql-general
Hi,

I'm trying to write an INSERT INTO statement that will use a DEFAULT
value when an input parameter is null.

Here's the function that fails to compile.  I tried replacing Coalesce
with a Case statement but that fails as well.  Note that if you
replace the condition with a simple 'Default' it compiles
successfully.  Any ideas?


CREATE OR REPLACE FUNCTION "name_add" (
    p_name varchar,
    p_created_date date
) RETURNS integer AS
$body$
DECLARE
BEGIN
    INSERT INTO names
    (
        name,
        created_date
    )
    VALUES
    (
        p_name,
        Coalesce(p_created_date, DEFAULT)
    );
    Return 1;
END ;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

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

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: generic modelling of data models; enforcing constraints dynamically...
Следующее
От: Sim Zacks
Дата:
Сообщение: Re: Using Insert - Default in a condition expression ??