Page 1 of 1

TMSStoredProc RETURN_VALUE does not return negative number returned by stored procedure

Posted: Thu 22 Nov 2018 19:01
by mguzman69
Hello,

I am new to DevArt, and migrating conectors to TMSXXXX, everything goes great until now!! I have a lot of SQL Server stored procedures, and by politics, when there are errors in the stored procedure (managed or not) we return a negative number, so we can know that the stored procedure was not executed sucefully. When whe use then Execute method and evaluate the params RETURN_VALUE, instead the negative number (i.e -10) I got an integer overflow number 4294967286, in every case.

Is there any way to get the correct RETURN_VALUE value whe returned the negative number ?

PD This works fine with TADOStoredProc and even with TFDStoredProc.

Thank you!

Re: TMSStoredProc RETURN_VALUE does not return negative number returned by stored procedure

Posted: Fri 23 Nov 2018 17:49
by mguzman69
Hello, I write a very simple example of the error I am getting :

The stored procedure in extreme simple example could be

CREATE PROCEDURE TEST
AS
RETURN -1

And the Delphi Code :

MSStoredProc1.StoredProcName := 'TEST';
MSStoredProc1.Execute;
ShowMessage( VarToStr( MSStoredProc1.ParamByName('RETURN_VALUE').Value ));

And the ShowMessahe show this :

4294967295

An Overflow integer.

Do you know how to fix this behavior ?

Thank you!

Re: TMSStoredProc RETURN_VALUE does not return negative number returned by stored procedure

Posted: Mon 26 Nov 2018 15:13
by Stellar
By default, in SDAC, the RETURN_VALUE parameter is of the Cardinal type, which is unsigned. To be able to get negative values, you should convert the Cardinal type to the Integer type, for example:

Code: Select all

ShowMessage( VarToStr( Integer(MSStoredProc1.ParamByName('RETURN_VALUE').AsLongWord)));