NULL values and string - Mailing list pgsql-general

From Sergey Karin
Subject NULL values and string
Date
Msg-id b78883bf0602020244s4e1e0e96o@mail.gmail.com
Whole thread Raw
Responses Re: NULL values and string  (Tino Wildenhain <tino@wildenhain.de>)
Re: NULL values and string  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Hi, List!

I'm using PG8.1.

Are there any abilities to represent NULL values as string?

I'm doing something like this:

create function func(int4) returns varchar as'
declare
    num_value alias for $1;
    string_value varchar;
begin
  
   string_value := \'input value = \' || num_value;
   return string_value;

end
'language 'plpgsql';


If I einvoke my function with NULL argument, it return NULL. But I want 'input value = NULL'.
Of course, I can check input value like this:

if(num_value isnull) then
   string_value := \'input value = NULL\';
else
   string_value := \'input_value = \' || num_value;
end if;

But it is not laconic...


Sergey Karin

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: storing XML and querying
Next
From: Tino Wildenhain
Date:
Subject: Re: NULL values and string