postgresql - POSTGRES COALESCE(NULLIF(c.name,''), 'unassigned') not working -
no version of character varying field return null
if there isn't value... it's frustrating
case when coalesce(nullif(e.name,''),'unassigned') null 'unassigned' else a.name end
was final test , still returns null
unless field has value
it's character varying(255)
coalesce(a.name,'unassigned') // won't work nullif(a.name,'') // won't work nullif(a.name,null) // won't work coalesce(nullif(a.name,''),'unassigned') // won't work
however instant use 0
works..
what's that?
it's character varying(255) field , set default null
as matter of point build of table column is
name varying character(255) default(null)
so know it's entering null , i've done
select * <tbl> name null;
, of course, return null rows a.name... what's deal this?
ok... deciding answer me with:
coalesce(nullif(e.name,''),'unassigned') null...
this method never work on return of "no records" , stored procedure creates materialized view, i'm polling via nested queries - possible column have 0
(as default id = other_id) nested query return no rows. when no row returned, functions of coalesce
or nullif
never execute. row have returned in order functions act upon row values... i've never heard of table pk auto-incremented field starting @ 0
, starting @ 1
resultset of "no records returned" return null value materialized view column.
the query run afterward poll rows materialized view function coalesce(etc etc)
because there actual null value in column.
Comments
Post a Comment