Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Gregory Scarborough — — source: Informix-list mailing list archive (1991-1998)
I am attempting to update a database column with the maximum of the
value currently stored in the column and the contents of a host
variable.
For example:
EXEC SQL UPDATE DB_TABLE
SET DB_COLUMN =
CASE WHERE DB_COLUMN > :hostVar
THEN DB_COLUMN
ELSE :hostVar
END;
When I compile and execute the above statement, I get a sqlca.sqlcode of
-800 (Corresponding types must be compatible in CASE expression).
I have run some tests and found that UPDATE will only succeed if the
contents of the THEN and ELSE in the CASE are identical. For instance:
CASE WHERE DB_COLUMN > :hostVar
THEN DB_COLUMN
ELSE DB_COLUNN2
END
or
CASE WHERE DB_COLUMN > :hostVar
THEN :hostVar
ELSE :hostVar2
END
It seems that host variables and column names are not considered
compatible expressions. This is contrary to the information in the
Informix SQL Syntax Guide.
Does anyone see anything wrong with my initial SQL or have another
suggestion for how to accomplish this task without doing a SELECT before
the UPDATE?
Thanks,
Gregory Scarborough
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.