Skip site navigation (1) Skip section navigation (2)

NULLS and string concatenation

From: Don Drake <dondrake(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: NULLS and string concatenation
Date: 2004-11-19 17:12:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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).


Donald Drake
Drake Consulting


pgsql-sql by date

Next:From: Bruno Wolff IIIDate: 2004-11-19 17:45:43
Subject: Re: NULLS and string concatenation
Previous:From: Tom LaneDate: 2004-11-19 17:08:50
Subject: Re: transactions in functions, possible bug or what I'm doing

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group