From: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
---|---|
To: | Archana Sachin Ghag <Archana_Ghag(at)infosys(dot)com> |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Issue with passing NULL for function parameter |
Date: | 2011-11-03 11:40:38 |
Message-ID: | 4EB27DB6.4070807@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 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
From | Date | Subject | |
---|---|---|---|
Next Message | Gary Kenney | 2011-11-03 16:35:36 | BUG #6285: PreparedStatement#executeUpdate gets syntax error on apostrophe |
Previous Message | Archana Sachin Ghag | 2011-11-03 11:32:52 | Issue with passing NULL for function parameter |