From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Archana Sachin Ghag <Archana_Ghag@infosys.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: Issue with passing NULL for function parameter
Date: Thu, 03 Nov 2011 13:40:38 +0200
Message-ID: <4EB27DB6.4070807@enterprisedb.com> (raw)
In-Reply-To: <EECE843AE50D6E4E85BE16173C1E84EB097579D1F7@PUNITPMBX01.ad.infosys.com>
References: <EECE843AE50D6E4E85BE16173C1E84EB097579D1F7@PUNITPMBX01.ad.infosys.com>
On 03.11.2011 13:32, Archana Sachin Ghag wrote:
> I have wriiten following simple function in postgresql
>
> CREATE OR REPLACE FUNCTION "MySchema".add_user(p_name character varying, p_email1 character varying, p_email2 character varying)
> RETURNS bigint AS
> $BODY$
> DECLARE
> userId bigint;
> BEGIN
> INSERT INTO "MySchema"."User"("Name" ,"EMail1" , "EMail2")
> VALUES ($1 , $2, $3) ;
>
> Select CURRVAL('"MySchema".user_seq_userid') into userId;
>
> return userid;
> END;
> $BODY$
> LANGUAGE plpgsql VOLATILE STRICT
>
> Function works absoolutely fine if I provide values for all three parameters. Record gets inserted too.
>
> But if I pass NULL for say last parameter, using SELECT "MySchema".add_user('A' , 'A', NULL)
> function does not do anything and return zero.
Yeah. That's what STRICT means.
http://www.postgresql.org/docs/9.1/static/sql-createfunction.html
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: heikki.linnakangas@enterprisedb.com, Archana_Ghag@infosys.com
Subject: Re: Issue with passing NULL for function parameter
In-Reply-To: <4EB27DB6.4070807@enterprisedb.com>
References: <EECE843AE50D6E4E85BE16173C1E84EB097579D1F7@PUNITPMBX01.ad.infosys.com> <4EB27DB6.4070807@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox