'How to avoid Invalid number string error in OpenEdge DB?

I am accessing an 11.7 OE Enterprise RDBMS. I have two simple queries, one which works another which doesn't. In the queries below the LAB_VALUE field is a varchar data type. The first query returns 106 rows with no issues. The second query dies immediately.

Query 1;

SELECT to_number(LAB_VALUE) LAB_VALUE 
FROM labrec_view
WHERE lab_yr_mon = 202006 AND 
      FACILITY_CODE = 'BUF' AND 
      LAB_RESULT_CODE = 'ALBUMIN'

Query2;

SELECT to_number(LAB_VALUE) LAB_VALUE 
FROM labrec_view
WHERE lab_yr_mon = 202006 AND 
      FACILITY_CODE = 'BUF' AND 
      LAB_RESULT_CODE = 'ALBUMIN' and
      to_number(LAB_VALUE) > 4 

The error received is;

SQLState=HY000
ErrorCode=-20232
[DataDirect][OpenEdge JDBC Driver][OpenEdge] Invalid number string (7498)

I am at a loss. There is an KB atricle;

https://knowledgebase.progress.com/articles/Article/Invalid-number-string-7498-returned-by-SQL-query-on-OE-10-2B

But it seems to refer to older versions of OpenEdge and specifically states 11.7 should correct the issue.

I am not a Progress DB person, and I only have access to query views in the DB as a specific R/O user.

Where do I go from here in troubleshooting?

Edit: Someone suggested the to_number (in the where clause) might be causing a problem because some data which I don't see may not be numeric. So I used the following query with the same error results;

SELECT LAB_VALUE_TEST
from 
(
    SELECT to_number(LAB_VALUE) LAB_VALUE_TEST 
    FROM labrec_view
    WHERE lab_yr_mon = 202106 AND 
          FACILITY_CODE = 'BUF' AND 
          LAB_RESULT_CODE = 'ALBUMIN'
) iq
WHERE iq.LAB_VALUE_TEST >4;


Solution 1:[1]

at a guess, because you're using an expression ( "to_number(LAB_VALUE) > 4" ) the LAB_VALUE field has to be checked to see if it is greater than 4

if there "where" phrase does not short-circuit then all labrec records have to be checked , and there may be some with an invalid value for a number

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jmls