Hi!

it would be great to have a coalesce2 function which treats empty strings as 
null values.

as far as I have seen, there are a lot of comments and coding solutions about 
this, but none is an "easy" one and all make the code a bit more complicated 
and more difficult to maintain.

I have created this function.
It's similar to nullif, but takes only  ONE argument

create or replace function "empty2null"(text_i varchar)
returns varchar as $$
declare
text_p varchar;
begin
if text_i = ''
 then text_p := null;
 else text_p := text_i;
end if;
return text_p;
end;
$$ LANGUAGE plpgsql;


-- 
cu
Ferdinand 

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to