![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your message can get through to the mailing list cleanly |
#3
| |||
| |||
|
|
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). |
#4
| |||
| |||
|
|
On Fri, Nov 19, 2004 at 11:12:38 -0600, Don Drake <dondrake (AT) gmail (DOT) com> wrote: I was able to work around the problem by using COALESCE (and casting variables since it wants the same data types passed to it). This is what you should do. |
#5
| |||
| |||
|
|
Don Drake wrote: 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? No. Null is "unknown" if you append unknown (null) to a piece of text, the result is unknown (null) too. If you're using NULL to mean something other than unknown, you probably want to re-examine your reasons why. |
#6
| |||
| |||
|
|
On Fri, 19 Nov 2004 17:48:34 +0000, Richard Huxton <dev (AT) archonet (DOT) com> wrote: Don Drake wrote: 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? No. Null is "unknown" if you append unknown (null) to a piece of text, the result is unknown (null) too. If you're using NULL to mean something other than unknown, you probably want to re-examine your reasons why. I'm using NULL to mean no value. Logically, NULL is unknown, I agree. I'm trying to dynamically create an INSERT statement in a function that sometimes receives NULL values. This is still strange to me. In Oracle, the same query would not replace the *entire* string with a NULL, it treats the NULL as a no value. |
|
I can't find in the documentation where string concatenation of any string and NULL is NULL. |
#7
| |||
| |||
|
|
This is still strange to me. In Oracle, the same query would not replace the *entire* string with a NULL, it treats the NULL as a no value. |
|
I can't find in the documentation where string concatenation of any string and NULL is NULL. |
#8
| |||
| |||
|
|
On Fri, Nov 19, 2004 at 11:12:38 -0600, Don Drake <dondrake (AT) gmail (DOT) com> wrote: I was able to work around the problem by using COALESCE (and casting variables since it wants the same data types passed to it). This is what you should do. |
![]() |
| Thread Tools | |
| Display Modes | |
| |