Why BCD Overflow?
Why BCD Overflow?
hello,
It seems i have a problem with TSQLStoredProc.
I have a stored procedure on Oracle, just the easy one with only one integer input param.
Let's use the following easy stored procedure on Oracle:
CREATE OR REPLACE PROCEDURE SP_TEST
( I_OPTYPE Integer) IS
BEGIN NULL; END;
I user: TSQLStoredProc(sp);
If i use like this:
sp.ParamByName('I_OPTYPE').AsInteger = 1, i get a BCD OverFlow error
If i use like this:
sp.ParamByName('I_OPTYPE').AsFTMBCD = IntegerToBcd(1) it works fine.
sp.ExecProc;
Why it doesn't work with AsInteger? or maybe i'm doing something wrong?
i'm using Kylix and dbexpress 3.0
Thanks
It seems i have a problem with TSQLStoredProc.
I have a stored procedure on Oracle, just the easy one with only one integer input param.
Let's use the following easy stored procedure on Oracle:
CREATE OR REPLACE PROCEDURE SP_TEST
( I_OPTYPE Integer) IS
BEGIN NULL; END;
I user: TSQLStoredProc(sp);
If i use like this:
sp.ParamByName('I_OPTYPE').AsInteger = 1, i get a BCD OverFlow error
If i use like this:
sp.ParamByName('I_OPTYPE').AsFTMBCD = IntegerToBcd(1) it works fine.
sp.ExecProc;
Why it doesn't work with AsInteger? or maybe i'm doing something wrong?
i'm using Kylix and dbexpress 3.0
Thanks
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
This error happens because parameter type (ftBCD) doesn't match parameter value (ftInteger). When
dbExpress sets the parameter it passes type of parameter, not the type of value that is stored in
the buffer. So there is no possibility for driver to determine what value is stored in the buffer.
That's why when the driver tries to get BCD number from the buffer that stores integer value, the BCD overflow error is raised. The standard Oracle dbExpress driver has the same behavior. Therefore to avoid this problem you should either assign values that match parameter datatype or use TSQLQuery.
dbExpress sets the parameter it passes type of parameter, not the type of value that is stored in
the buffer. So there is no possibility for driver to determine what value is stored in the buffer.
That's why when the driver tries to get BCD number from the buffer that stores integer value, the BCD overflow error is raised. The standard Oracle dbExpress driver has the same behavior. Therefore to avoid this problem you should either assign values that match parameter datatype or use TSQLQuery.
Thanks for the answer.
I cannot change the database structure
I have an existing application developped under Builder5
and I convert this application to Builder 2006
So I would like to replace the BDE Builder component
by the DbExpress whith the minimum changing.
a lot of stored procedures exist in the existing oracle database
whith INTEGER type parameter.
in the object inspector the DataType is automatically replace
by ftBCD DataType.
if I call
pMyStoredProc->ParamByName("I_MYINTEGER")->AsBCD = myInteger;
I have a Oracle error ( ORA-06512).
If I call
pMyStoredProc->ParamByName("I_MYINTEGER")->AsInteger = myInteger;
I have a BCD Overflow.
Is it a way to resolve my problem ?
I cannot change the database structure
I have an existing application developped under Builder5
and I convert this application to Builder 2006
So I would like to replace the BDE Builder component
by the DbExpress whith the minimum changing.
a lot of stored procedures exist in the existing oracle database
whith INTEGER type parameter.
in the object inspector the DataType is automatically replace
by ftBCD DataType.
if I call
pMyStoredProc->ParamByName("I_MYINTEGER")->AsBCD = myInteger;
I have a Oracle error ( ORA-06512).
If I call
pMyStoredProc->ParamByName("I_MYINTEGER")->AsInteger = myInteger;
I have a BCD Overflow.
Is it a way to resolve my problem ?
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53