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;

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to