NULLS and string concatenation - Mailing list pgsql-sql

From Don Drake
Subject NULLS and string concatenation
Date
Msg-id 6c21003b0411190912630d4afe@mail.gmail.com
Whole thread Raw
Responses Re: NULLS and string concatenation  (Bruno Wolff III <bruno@wolff.to>)
Re: NULLS and string concatenation  (Richard Huxton <dev@archonet.com>)
List pgsql-sql
I have a function that uses an execute statement to insert data into a
table, I do in my implementation of table partitioning.

Anyway, I ran into trouble when NULL values were being passed in
(fields are nullable) and my insert statement turned into a big NULL.

Here's an equivalent statement that caused trouble:

select 'some text, should be null:'|| NULL

This returns NULL and no other text.  Why is that?  I wasn't expecting
the "some text.." to disappear altogether.

Is this a bug?

I was able to work around the problem by using COALESCE (and casting
variables since it wants the same data types passed to it).

-Don

-- 
Donald Drake
President
Drake Consulting
http://www.drakeconsult.com/
312-560-1574


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: transactions in functions, possible bug or what I'm doing
Next
From: Bruno Wolff III
Date:
Subject: Re: NULLS and string concatenation