Re: Issue with passing NULL for function parameter - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: Issue with passing NULL for function parameter
Date
Msg-id 4EB27DB6.4070807@enterprisedb.com
Whole thread Raw
In response to Issue with passing NULL for function parameter  (Archana Sachin Ghag <Archana_Ghag@infosys.com>)
List pgsql-bugs
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
charactervarying) 
>    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

pgsql-bugs by date:

Previous
From: Archana Sachin Ghag
Date:
Subject: Issue with passing NULL for function parameter
Next
From: "Gary Kenney"
Date:
Subject: BUG #6285: PreparedStatement#executeUpdate gets syntax error on apostrophe