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

Re: How to avoid nulls while writing string for dynamic query

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Kumar <sgnerd(at)yahoo(dot)com(dot)sg>
Cc: psql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to avoid nulls while writing string for dynamic query
Date: 2004-02-12 12:43:32
Message-ID: 402B74F4.7070604@klaster.net (view raw or flat)
Thread:
Lists: pgsql-sql
Dnia 2004-02-12 13:31, Użytkownik Kumar napisał:
> The error is because of no value for column c1. If the column c1 is a 
> string I might have replace it with empty string. I don't want to 
> substitute with '0' which could work.
>  
> sqlstr := 'insert into test(c1, c2) values (' ||ISNULL(rec.c1,'0')||','
>                                                                     
> ||'\''||rec.c2||'\')';

Substitute it with NULL value:
sqlstr := 'insert into test(c1, c2) values(' || coalesce(rec.c1,'NULL') 
||...

Regards,
Tomasz Myrta

In response to

Responses

pgsql-sql by date

Next:From: owDate: 2004-02-12 14:05:16
Subject: Re: 7.4 - FK constraint performance
Previous:From: KumarDate: 2004-02-12 12:31:12
Subject: How to avoid nulls while writing string for dynamic query

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