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-13 06:33:28
Message-ID: 402C6FB8.8000606@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Kumar 2004-02-13 07:13:26 Re: How to avoid nulls while writing string for dynamic query
Previous Message David Witham 2004-02-13 05:58:32 Re: Index question