Re: Passing nulls into PL/pgSQL functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adam Witney <awitney(at)sghms(dot)ac(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Passing nulls into PL/pgSQL functions
Date: 2003-04-16 20:31:31
Message-ID: 362.1050525091@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adam Witney <awitney(at)sghms(dot)ac(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeffrey Melloy 2003-04-16 21:16:40 Cocoa Apps
Previous Message Adam Witney 2003-04-16 20:09:53 Passing nulls into PL/pgSQL functions