Skip site navigation (1) Skip section navigation (2)

Re: passing values to a function

From: Cedar Cox <cedarc(at)visionforisrael(dot)com>
To: Jan Wieck <janwieck(at)Yahoo(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: passing values to a function
Date: 2001-02-19 22:19:09
Message-ID: Pine.LNX.4.21.0102200003440.31428-100000@nanu.visionforisrael.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
> > Why does this not work?  Am I doing something wrong?
..
> >   raise notice '' varop is '',varop;
> 
>     raise notice '' varop is %'', varop;

Arrrg!  How did I miss that one.. I've been writing notice lines for
months now!

Ok, well I seem to have found the "real" problem this time ;)

CREATE FUNCTION update_sentitems(text,int4) RETURNS bool AS '
declare
  varop alias for $1;
begin
  raise notice '' varop = %'',varop;
  return false;
end;
' LANGUAGE 'plpgsql';

Giving
  select update_sentitems('INSERT',1);
returns
  NOTICE:   varop = INSERT
as expected, however if you give
  select update_sentitems('INSERT',null);
this is returned:
  NOTICE:   varop = <NULL>

BTW, it doesn't matter if both parameters are text or int4.  Also, it
doesn't matter which one is given as null, they both turn up null.  
Bottom line seems to be that if you call the function with any parameter
null, they are all null.  Sooo.. what's up here?  Is this a bug that's
been fixed in 7.0.3? (I'm still using 7.0.2).

Thanks
-Cedar


In response to

Responses

pgsql-interfaces by date

Next:From: Tom LaneDate: 2001-02-19 23:24:25
Subject: Unportable code in odbc's dlg_specific.h
Previous:From: Adam HaberlachDate: 2001-02-19 20:07:31
Subject: First-time JDBC setup with Jakarta! Whee!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group