Any ideas on why my the result 'green' row
column DELTA does not yield -1 for?
That is not how I expected COALESCE( ... ) to work.
Every other row for DELTA (including 'black')
comes out the way I expected.
Thanks for considering this,
John G.
note: running as400, on V5-R2
create table blarch (
a char(10),
b char(10)
);
insert into blarch values( 'red', '123' );
insert into blarch values( 'blue', '0' );
insert into blarch values( 'green', '' );
insert into blarch values( 'black', null );
select
'>>' || a || '<<' as ALPHA ,
'>>' || b || '<<' as BETA ,
cast( b as INTEGER) as GAMMA,
coalesce( cast( b as INTEGER), -1 ) as DELTA
from blarch;
test
| ALPHA | BETA | GAMMA | DELTA |
+--------------+--------------+-----------+-----------+
|>>red <<|>>123 <<| 123| 123|
|>>blue <<|>>0 <<| 0| 0|
|>>green <<|>> <<| -| -|
|>>black <<|- | -| -1|
+--------------+--------------+-----------+-----------+