Does anyone have a document or bug reference with respect to how progress is managing a cast of a numeric which is too large for the target character field.
It would appear that Progress does not throw an exception but prefers to return asterisks which is not per the standard. It would appear that cast wants to add a trailing space which is also incorrect.
For example, this should return 10.23 as a char type but does not as it overflows as "**** "
select distinct cast ( cast ( 10.23 as decimal (4,2)) as char(5)) from sometable
Meanwhile this works as it allows for the unexpected trailing space
select distinct cast ( cast ( 10.23 as decimal (4,2)) as char(6)) from PRODUCT
What do you expect when you don't give it enough space?
an overflow exception should be thrown.
And, why would you expect that in a language that has yet to acquire exceptions?
And, given that you would have to code to handle the exception gracefully, the code required to handle this without exceptions is really quite simple.
E.g., try out something like this.
DEFINE VARIABLE X AS CHARACTER.
ASSIGN X = STRING(99999,"9999") NO-ERROR.
DISPLAY X ERROR-STATUS:ERROR ERROR-STATUS:NUM-MESSAGES
SKIP ERROR-STATUS:get-message(1) FORMAT "X(60)".
I'm referring to what the SQL standard requires.
Consider a case where an exception is thrown
select cast ( systime() as char(2))
from "GOSALES1"."GOSALES1"."ORDERHEADER" "ORDERHEADER"
SQLFetch returned: SQL_ERROR=-1
: szSqlState = "HY000", *pfNativeError = -20152, *pcbErrorMsg = 102
szErrorMsg = "[DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Character string is too long (8184)"
Consider the case where it is not and further where the target field is in fact large enough if Progress were not trying to add a blank on the end.
select distinct cast ( cast ( 10.2 as decimal(3,2)) as char(4))
from "GOSALES1"."GOSALES1"."ORDERHEADER" "ORDERHEADER"
"convert(character(4,0),convert(numeric(3,2),10.200000))"
"*** "
1 row fetched from 1 column.
select distinct cast ( cast ( 10.2 as decimal(3,2)) as char(5))
from "GOSALES1"."GOSALES1"."ORDERHEADER" "ORDERHEADER"
Get Data All:
"convert(character(5,0),convert(numeric(3,2),10.200000))"
"10.2 "
1 row fetched from 1 column.