Re: Postgres mystery

From: Berend Tober <btober(at)seaworthysys(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Shaun Clements <ShaunC(at)relyant(dot)co(dot)za>, pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres mystery
Date: 2005-03-30 14:41:49
Message-ID: 424ABAAD.8060304@seaworthysys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Fuhr wrote:

>On Wed, Mar 30, 2005 at 09:11:09AM +0200, Shaun Clements wrote:
>
>
>>Can anyone tell me what the problem is here:
>>I am inserting into a table via a stored procedure, to a few columns within
>>the table and postgres is throwing a
>>CANNOT EXECUTE NULL QUERY.
>>
>>EXECUTE ''INSERT INTO table (column1, column2, column3,
>>''||quote_ident(column4)||'') values
>>(''||quote_literal(RECORDNAME.column1)||'',''||quote_literal(RECORDNAME.colu
>>mn2)||'',''''stringvalue'''',''||quote_literal(RECORDNAME.column2)||'')'';
>>
>>
>
>One of the operands to || is probably NULL, so the entire INSERT
>string ends up being NULL. Example:
>
>SELECT 'abc' || 'def';
> ?column?
>----------
> abcdef
>(1 row)
>
>SELECT 'abc' || NULL;
> ?column?
>----------
>
>(1 row)
>
>Looks like you need to check for NULL or use COALESCE to convert
>NULL to something else.
>
>
>
That something else you ought to do appears in the documentation User
Comments at

http://www.postgresql.org/docs/8.0/interactive/functions-conditional.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Roberto Chamorro Mostac 2005-03-30 14:42:53 Postgres Processing Help !!!!
Previous Message Shaun Clements 2005-03-30 14:34:25 Re: Postgres plpgsql