Question
· Jul 6, 2021

Cache numeric comparison via ODBC something is not working

How strange this is to me.  I'm querying a table against a numeric(15,2) column call max_client_resp_service.  When I query max_client_resp_service > 0 or any number, I get results, but they are not always right, for example where max_client_resp_service > 5 returns values less than 5, e.g. 2.00.  When I query < 110 of any higher number I get zero results.  It's as though the comparison operator, especially less than function is not working.  See attachments for screen shots.  I'm stumped.  Ok looking at this further, it appears ">" returns all records, "<" returns no results.

Product version: Caché 2017.1
$ZV: Cache 2017.2.2 (Build 867_4_20245)
Discussion (6)2
Log in or sign up to continue

I don't know the answer but you could try to query the max_cover_partdays or other numeric without decimal part to check if it causes issues. Or try to add it to your query, something like <109.99

It looks to me like there's some casting or parseing type ocurring somehow and greater than X just checks if the value is not null?

I never had any issue like this, besides dealing with decimal separator between systems or dealing with null and empty value conversions/replacements to avoid runtime exceptions.

I found a work around, using to_number function around the column query, e.g. where to_number(max_client_resp_service) < 110 yields correct results.  So strange it's as if the numeric(15,2) column is being stored or queried as an varchar string.  Perhaps there's a wrong typed index on this column, but I can't seem to determine the index type if any on this column from INFORMATION_SCHEMA.INDEXES.