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

2004-02-13 Thread Tomasz Myrta
Dnia 2004-02-13 10:14, Użytkownik Kumar napisał: Thanks Tomasz Myrta. It is wonderful. I am still amazed from where you guys knowing the options like quote_literal, etc. Kumar Just read the manual ;-) 6.4. String Functions and Operators Tomasz ---(end of broadcast)-

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

2004-02-13 Thread Kumar
PROTECTED]> Sent: Friday, February 13, 2004 1:37 PM Subject: Re: [SQL] How to avoid nulls while writing string for dynamic query > Dnia 2004-02-13 08:13, Użytkownik Kumar napisał: > > oh, ok understood. > > What will happen for a timestamp field. Let us say c1 is a times

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

2004-02-13 Thread Tomasz Myrta
Dnia 2004-02-13 08:13, Użytkownik Kumar napisał: oh, ok understood. What will happen for a timestamp field. Let us say c1 is a timestamp column. sqlstr := 'insert into test(c1, c2) values ('||'\''||COALESCE(rec.c1,'NULL')||'\',' ||'\''||rec.c2||'\')'; If this case the query will be insert

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

2004-02-12 Thread Kumar
tation 'NULL' I think using 'CASE' this could be solved. But instead is there any other simple way to do it. Thanks a lot Mr. Tomasz Myrta Kumar - Original Message - From: "Tomasz Myrta" <[EMAIL PROTECTED]> To: "Kumar" <[EMAIL PROTECTED]&

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

2004-02-12 Thread Tomasz Myrta
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

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

2004-02-12 Thread Kumar
TECTED]> To: "Tomasz Myrta" <[EMAIL PROTECTED]> Cc: "psql" <[EMAIL PROTECTED]> Sent: Friday, February 13, 2004 10:23 AM Subject: Re: [SQL] How to avoid nulls while writing string for dynamic query > I am having problem there. see what happens > > sqlstr :

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

2004-02-12 Thread Kumar
TED]> To: "Kumar" <[EMAIL PROTECTED]> Cc: "psql" <[EMAIL PROTECTED]> Sent: Thursday, February 12, 2004 6:13 PM Subject: Re: [SQL] How to avoid nulls while writing string for dynamic query > Dnia 2004-02-12 13:31, Użytkownik Kumar napisał: > > The

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

2004-02-12 Thread Tomasz Myrta
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')||','

[SQL] How to avoid nulls while writing string for dynamic query

2004-02-12 Thread Kumar
Dear Friends,   Postgres 7.3.4 on RH Linux 7.2.   I wanted to write a dynamic query for insert statement.   create table test(c1 int, c2 varchar)   insert into test(c1, c2) values (1,'Hai1');insert into test(c1, c2) values (NULL,'Hai2');   so I wrote a function called test_fn()   DECLARE    s