I want to use a CASE Statement to check a parameter conditionally like if parameter is an empty string I want to return Nil if not then string 'test' but this does not work. Also I don’t want to use COALESCE
select TEST=CASE '' WHEN '' THEN 'Nil' ELSE 'Test' END,current_timestamp from sysibm.sysdummy1;
I get an error
SQL State: 42601
Vendor Code: -104
Message: [SQL0104] Token = was not valid. Valid tokens: + – AS . Cause . . . . . : A syntax error was detected at token =. Token = is not a valid token. A partial list of valid tokens is + – AS . This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery . . . : Do one or more of the following and try the request again: — Verify the SQL statement in the area of the token =. Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. — If the error token is , correct the SQL statement because it does not end with a valid clause.
Replace something by the intended column.
For more info, check THIS.