RE: [HACKERS] PL/pgSQL a great procedural language for PostgreSQL

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: "Jose' Soares" <jose(at)sferacarta(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: RE: [HACKERS] PL/pgSQL a great procedural language for PostgreSQL
Date: 1998-11-04 19:52:39
Message-ID: F10BB1FAF801D111829B0060971D839F4CF2D5@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

It appears that when a function is called if any of the paramaters are
NULL all of the parameters are NULL.
try:
drop function nvl(int, int);
create function nvl(int, int) returns boolean as '
declare
nonullo alias as $1;
nullo alias as $2;
begin
return (nonullo IS NULL) AND (nullo IS NULL);
end;' language 'plpgsql';
select nvl(i,0) from a;
you should get:
nvl
---
t
t
f
t
(4 rows)

> Hi all,
>
> ----I'm trying to understand this very interesting language PL/pgSQL
> thanks to Jan Wieck,
> ----finally we can trap NULL values as in:
>
> -------and seems it returns only constant values:
>
> drop function nvl(integer,integer);
> DROP
> create function nvl(integer,integer) returns integer as '
> declare
> nonullo alias for $1;
> nullo ALIAS FOR $2;
> begin
> if NONULLO then
> return NONULLO;
> else
> return NULLO;
> end if;
> end;' language 'plpgsql';
> CREATE
>
> select nvl(i,0) from a;
> nvl
> -------
>
>
> 2232767
>
> (4 rows)
>
> Jose'

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-11-04 20:01:40 Re: [HACKERS] latest snapshot crashes backend
Previous Message Marcus Mascari 1998-11-04 19:33:02 PLEASE...SOMEONE COMMENT: PostgreSQL 6.4BETA not using indexes with subselects