From: | Sferacarta Software <sferac(at)bo(dot)nettuno(dot)it> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org, Vince Vielhaber <vev(at)michvhf(dot)com> |
Subject: | Re[2]: AW: [HACKERS] isnull() or is it?t |
Date: | 1998-12-10 13:41:17 |
Message-ID: | 10612.981210@bo.nettuno.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
If it is interesting to someone, we can partially emulate COALESCE
right now as:
create function coalesce(integer) returns integer as
'declare
nonullo alias for $1;
begin
if nonullo then
return nonullo;
else
return 0;
end if;
end;
' language 'plpgsql';
CREATE
select *,coalesce(comm) from emp where comm is null;
ename|empno|job | hiredate|sal |comm|deptno|level| mgr|coalesce
-----+-----+----------+----------+---------+----+------+-----+----+--------
BLAKE| 7698|MANAGER |1981-05-01|$2,850.00| | 30| 3|7782| 0
JONES| 7900|CLERK |1981-12-03|$950.00 | | 30| 2|7782| 0
CLARK| 7844|SALESMAN |1981-09-08|$1,500.00| | 10| 2|7839| 0
(3 rows)
-Jose'-
>> > > With SyBase, IsNull(X,Y) returns X if X is not null, and Y
>> > > if X is null.
>> >
>> > Which is identical in behavior to the SQL92-defined function
>> > COALESCE(X,Y) (IsNull() is not in the standard). This is now in the
>> > Postgres development tree, to be available in the next release. Should
>> > we also have the less capable IsNull() available too? COALESCE() has the
>> > nice feature that it takes an unlimited number of arguments, returning
>> > the first non-null result.
>>
>> Oh, NVL and isnull are not standard? Then let's just use coalesce. I
>> will remove them from the TODO list.
VV> Surprises me too. I was under the (incorrect) impression that isnull
VV> was standard.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1998-12-10 15:48:41 | Re: [HACKERS] Date/time on glibc2 linux |
Previous Message | Sferacarta Software | 1998-12-10 13:31:59 | Re[2]: [HACKERS] gram.y |