Page 1 of 1

where condition in update statement issue

Posted: Tue Oct 17, 2017 10:16 pm
by India2000
Hi
I have a scenario where I want to update a table for records with date column is null

If I use generated query with date as a key column, job doesn't update anything in the table.

I think custom query doesn't accept Date is null and job fails if I use it.


Could any of you please let me know how to handle this situation?

Thanks,

Posted: Wed Oct 18, 2017 7:11 am
by chulett
A bit lost. Why don't we start with you posting the generated SQL? If you are passing in a value of NULL to a where clause that says where your "date column" *equals* that passed in value, then yes it will never work.

What database is this?

Posted: Wed Oct 18, 2017 8:14 am
by India2000
DB2 ..tried ...UPDATE SCHEMA.TABLE SET COL1 = ORCHESTRATE.COL1, COL2 = ORCHESTRATE.COL_2 WHERE ( KeY_COL1 = ORCHESTRATE.KeY_COL1 AND DATE=ORCHESTRATE.DATE)



UPDATE SCHEMA.TABLE SET COL1 = ORCHESTRATE.COL1, COL2 = ORCHESTRATE.COL_2 WHERE ( KeY_COL1 = ORCHESTRATE.KeY_COL1 AND DATE IS NULL)

Posted: Wed Oct 18, 2017 8:58 am
by India2000
I used NVL to handle this scenario. andit worked. thanks

Posted: Wed Oct 18, 2017 9:33 am
by chulett
Right. Exactly.