I've been recently writing queries for DB2 on an IBM iSeries box. I know about the "CASE" keyword, but it's not working for me. I keep receiving this error message: Keyword CASE not expected. Here's one of my sample code:
IF EXISTS ( SELECT * FROM MYTABLE WHERE KEY = xxx )
THEN UPDATE MYTABLE SET VALUE = zzz WHERE KEY = xxx
ELSE INSERT INTO MYTABLE (KEY, VALUE) VALUES (xxx, zzz)
Could someone tell me a way to do this against DB2 on IBM iSeries? I have to run two queries, first a select and then the Java code decides to update/insert. I would rather just write on query. Thanks!