Re: How to avoid nulls while writing string for dynamic query - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: How to avoid nulls while writing string for dynamic query
Date
Msg-id 402B74F4.7070604@klaster.net
Whole thread Raw
In response to How to avoid nulls while writing string for dynamic query  ("Kumar" <sgnerd@yahoo.com.sg>)
List 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


pgsql-sql by date:

Previous
From: "Kumar"
Date:
Subject: How to avoid nulls while writing string for dynamic query
Next
From: ow
Date:
Subject: Re: 7.4 - FK constraint performance