Functions with Null Arguments? - Mailing list pgsql-sql

From Thomas Swan
Subject Functions with Null Arguments?
Date
Msg-id 5.0.0.11.2.20000815010809.01e52570@sunset.backbone.olemiss.edu
Whole thread Raw
Responses Re: Functions with Null Arguments?  (Jesus Aneiros <aneiros@jagua.cfg.sld.cu>)
List pgsql-sql
<br /> Is there anyway way to get the following to work?<br /><br /><font face="Courier, Courier">table foo<br /> id |
name1  | name2<br /> ---+---------+------<br />  0 | Abe     | NULL<br />  1 | William | Bill<br /><br /><br
/></font>createfunction prefname(text, text)<br /> returns text as'<br /> declare<br />         name1 alias for $1;<br
/>        name2 alias for $2;<br /> begin<br />         if name2 isnull<br />         then<br />                 return
name1;<br/>         else<br />                 return name2;<br />         end if;<br /> end;'<br /> language
'plpgsql';<br/>  <br />  if I do<br /> select id, name1, name2, prefname(name1, name2) as pref from foo;<br /><br /> I
windup with <br /><br /><font face="Courier, Courier">id | name1   | name2 | prefname<br />
---+---------+-------+-----------<br/>  0 | Abe     | NULL  | NULL<br />  1 | William | Bill  | Bill<br /><br
/></font>insteadof <br /><br /><font face="Courier, Courier">id | name1   | name2 | prefname<br />
---+---------+-------+-----------<br/>  0 | Abe     | NULL  | Abe<br />  1 | William | Bill  | Bill<br /><br /></font>
Iassume this has to do with Postgres not executing the function is one of the arguments is missing...<br /><br /><br />
-<br /> - <b><u>Thomas Swan</u></b>                                   <br /> - Graduate Student  - Computer Science<br
/>- The University of Mississippi<br /> - <br /> - "People can be categorized into two fundamental <br /> - groups,
thosethat divide people into two groups <br /> - and those that don't." 

pgsql-sql by date:

Previous
From: Jesus Aneiros
Date:
Subject: RE: select an entry with a NULL date field
Next
From: Martin Dolog
Date:
Subject: My Indices doesn't work