• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

COALESCE Function in TIMESTAMP

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the following piece of code...

UPDATE TEST_TBL
SET
A_VALUE = ?,
B_VALUE = ?,
DATE_UPDATED = ?
WHERE ((coalesce(A_VALUE ,0) <> coalesce(?,0))
OR
(coalesce(B_VALUE ,0) <> coalesce(?,0))
OR
(coalesce(DATE_UPDATED,0) <> coalesce(?,0)))

The above query throws an error since DATE_UPDATED which is of type DATE and it cannot be assinged to '0'.
Can you please suggest what could be assigned?

NOTE: I have tried with Single quotes[' '], it also fails.


Thanks in Advance
Praveen.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC Forum.
 
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with what ever knowledge I have, I think Coalesce statements are used in the Query part of the statement (select) and not in the where part, even if you can, the LHS should resolve to be a Column Name and you cannot use a literal like like "where 10 = 0".

if you are also using Java then you could do most of the validations in the code itself before making the JDBC call

Originally posted by PraveenKumar Kannankutty:
WHERE ((coalesce(A_VALUE ,0) <> coalesce(?,0))
OR
(coalesce(B_VALUE ,0) <> coalesce(?,0))
OR
(coalesce(DATE_UPDATED,0) <> coalesce(?,0)))


[ October 25, 2005: Message edited by: RajaniKanth Bhargava ]
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by PraveenKumar Kannankutty:

Can you please suggest what could be assigned?



Instead of 0 try using a real date that wouldn't exist in your data like 1/1/1900, 1/1/2000, or 1/1/2500.
 
reply
    Bookmark Topic Watch Topic
  • New Topic