From: | "Jose' Soares" <jose(at)sferacarta(dot)com> |
---|---|
To: | "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | PL/pgSQL a great procedural language for PostgreSQL |
Date: | 1998-11-04 11:20:53 |
Message-ID: | 36403895.CB70BDF0@sferacarta.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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:
create function len(text) returns text as '
declare
nonullo alias for $1;
begin
if nonullo then
return length(nonullo);
else
return ''<NULL>'';
end if;
end;' language 'plpgsql';
CREATE
select len(c) from a;
len
------
12
<NULL>
<NULL>
<NULL>
12
(5 rows)
------I'm trying to create a function that returns a value instead of
NULL.
------The following one works well:
create function nvl(integer) returns integer as '
declare
nullo integer := 0;
nonullo alias for $1;
begin
if NONULLO then
return NONULLO;
else
return NULLO;
end if;
end;' language 'plpgsql';
CREATE
select nvl(i) from a;
nvl
-------
0
0
2232767
0
(4 rows)
------I would like to report this little thing, seems PL/pgSQL isn't
case insensitive:
drop function nvl(integer,integer);
DROP
create function nvl(integer) returns integer as '
declare
NULLO integer := 0;
NONULLO alias for $1;
begin
if NONULLO then
return NONULLO;
else
return NULLO;
end if;
end;' language 'plpgsql';
CREATE
select nvl(i) from a;
ERROR: attribute 'nonullo' not found
-------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'
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 1998-11-04 11:27:34 | Re: [HACKERS] update and select |
Previous Message | Jan Wieck | 1998-11-04 10:41:24 | Re: [HACKERS] A small problem with the new inet and cidr types |