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 402C6FB8.8000606@klaster.net
Whole thread Raw
In response to Re: How to avoid nulls while writing string for dynamic query  ("Kumar" <sgnerd@yahoo.com.sg>)
List pgsql-sql
Dnia 2004-02-13 05:53, Użytkownik Kumar napisał:

> I am having problem there. see what happens
> 
> sqlstr := 'insert into test(c1, c2) values ('||COALESCE(rec.c1,'NULL')||','
>         ||'\''||rec.c2||'\')';

You are preparing a string, so make sure you have strings everywhere:
sqlstr := 'insert into test(c1, c2) values 
('||COALESCE(rec.c1::text,'NULL')||','||'\''||rec.c2||'\')';

Regards,
Tomasz Myrta



pgsql-sql by date:

Previous
From: "David Witham"
Date:
Subject: Re: Index question
Next
From: Mona
Date:
Subject: How to unsubscribe