TMSStoredProc RETURN_VALUE does not return negative number returned by stored procedure

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mguzman69
Posts: 3
Joined: Thu 22 Nov 2018 18:54

TMSStoredProc RETURN_VALUE does not return negative number returned by stored procedure

Post by mguzman69 » Thu 22 Nov 2018 19:01

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!

mguzman69
Posts: 3
Joined: Thu 22 Nov 2018 18:54

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

Post by mguzman69 » Fri 23 Nov 2018 17:49

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!

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

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

Post by Stellar » Mon 26 Nov 2018 15:13

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)));

Post Reply