Composite fields and null - 06-26-2012 , 11:15 AM
I've got a composite field:
CREATE TYPE my_type AS (
and I'm going a db conversion that is taking an existing part1 value and based
on it, creating a my_type with a compiuted part2. I have a function to do it
CREATE FUNCTION fill_in_part2(part1 varchar) RETURNS my_type AS $$
IF part1 = NULL
new_part.part2 = 'ferret';
$$ LANGUAGE 'plpgsql';
The problem is that if part1 is null I get (,), that is a non-null thing that
has each of it's parts null. I really really want to return "true" null rather
then "composite" null. Has anyone any ideas?
There are several fields involved so I can't do add a "where part1 is not
null" clause. So far the best I can come up with is doing, for each effected
update table set my_new_part = null where (my_new_part).part1 = null;
Re: Composite fields and null - 06-28-2012 , 07:09 AM
On 2012-06-26, Steve Rogerson <steve (AT) nemodtcwey (DOT) co.uk> wrote:
IF part1 IS NULL
works for me.
3: Alternatively have you tried declaring the function as
"RETURNS NULL ON NULL INPUT"
⚂⚃ 100% natural
--- Posted via news://freenews.netfront.net/ - Complaints to news (AT) netfront (DOT) net ---