I use Firebird 2.1, DBExpress Driver from DevArt and Delphi 2010. Some of my reports, which were used to work with Delphi 2006, stopped working and issued an error message indicating that "arithmetic exception, numeric overflow or line truncation" had occurred. An error occurred at this point in my code:
cds.Data := dsProvider.Data;
I found a place in my SQL statement that caused the error:
iif(ytd.hPayType <> -1,t.sCode, 'NET') sPayType
T.sCode - Varchar field (10). My conclusion is that the query returns data to dsProvider and that when dsProvider.Data is passed to cds.Data, the cds component sets the field width based on the first value it receives. I get the same error message if I change "iif" to a CASE statement. I was able to solve the problem by following these steps:
CAST(iif(ytd.hPayType <> -1,t.sCode, 'NET') AS varchar(10)) sPayType
Since this was used to work in Delphi 2006 without CAST, I assume that the new behavior is related to updating TClientDataset. It would be nice to have old, more forgiving behavior. Is there a way to configure ClientDataset to accept this without complaint or do I just need to tell my CAST users about string results based on iif and CASE statements?
source share