Re: Passing nulls into PL/pgSQL functions - Mailing list pgsql-general

From Tom Lane
Subject Re: Passing nulls into PL/pgSQL functions
Date
Msg-id 362.1050525091@sss.pgh.pa.us
Whole thread Raw
In response to Passing nulls into PL/pgSQL functions  (Adam Witney <awitney@sghms.ac.uk>)
List pgsql-general
Adam Witney <awitney@sghms.ac.uk> writes:
> Is it possible to pass a null value into a PL/pgSQL function.

Certainly.

Your problem is with the EXECUTE, or even more specifically with the
string concatenation expression you're using to build the EXECUTE
expression.  Do you really need an EXECUTE here at all?  If so,
something involving COALESCE would work.  I'd try

EXECUTE ''INSERT ....'' || coalesce(quote_literal(_name), ''NULL'') || '')'';

            regards, tom lane


pgsql-general by date:

Previous
From: Adam Witney
Date:
Subject: Passing nulls into PL/pgSQL functions
Next
From: Jeffrey Melloy
Date:
Subject: Cocoa Apps