StoredProc Firemonkey Exception Handling

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
osmantaskiran
Posts: 15
Joined: Thu 21 Apr 2005 22:02

StoredProc Firemonkey Exception Handling

Post by osmantaskiran » Sun 15 Mar 2015 22:56

Hi,
I am creating a TUniStoredProc object on the fly.
I can execute it via ExecProc method. The storedproc contains some rules for input parameter values.

I sent incorrect parameter values to storedproc, it executed successfully without any exception also i could not handle exception. It did not return any exception.

What is the problem?

My Sql Server: 2012 Standart Edition
Component Version: 6.0.2
Android Ver: 4.2.2
IDE: Delphi XE7
Mode: Direct Mode

Stored Proc contains raise message:
-----------------------------------------------
Raiserror('Test-Brake Message',16,1);
return;
--------------------------------------------------


Thanks

Example:
--------------
try
with TUniStoredProc.Create(nil) do
begin
try
Connection := DataM.SDB;
StoredProcName := 'spSampleProc';
Prepare;
Params.ParamByName('param1').AsInteger := 1;
Params.ParamByName('param2').AsString := '1';
Params.ParamByName('param3').asFloat := 0;
Params.ParamByName('param4').Asstring := 'test';
ExecProc;

finally
Free;
end;
except on E:exception do
begin
ExceptionLog('Exception:'+E.Message);
end;
---------------------------------------


end;

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: StoredProc Firemonkey Exception Handling

Post by azyk » Wed 18 Mar 2015 11:36

Unfortunately, we can't reproduce the described problem. Please provide the script for creating the spSampleProc stored procedure, which reproduces the issue.

osmantaskiran
Posts: 15
Joined: Thu 21 Apr 2005 22:02

Re: StoredProc Firemonkey Exception Handling

Post by osmantaskiran » Wed 18 Mar 2015 12:46

Hi Again,

Thank you for your reply.

I use same sql server stored procedure both of my desktop software and my mobile application.

My stored procedure contains :

"if (bla bla bla)
begin
raiserror('Error Condition: XXXXX',16,1);
IF @@TRANCOUNT>0
rollback tran;
return
end"


Desktop application can handle this raiserror message and creates exception.
But mobile application can not handle raiserror and does not create any exception in my mobile software code block.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: StoredProc Firemonkey Exception Handling

Post by azyk » Fri 20 Mar 2015 11:45

Please clarify whether an exception occurs on executing the following stored procedure on your Android device.

The stored procedure creating script:

Code: Select all

CREATE PROCEDURE spRaiserror
AS 
Raiserror('Test-Brake Message',16,1);
return;
The code for calling the stored procedure:

Code: Select all

try
  with TUniStoredProc.Create(nil) do
    try
      Connection := DataM.SDB;
      StoredProcName := 'spRaiserror';
      Prepare;
      ExecProc;
    finally
      Free;
    end;
except
  on E: exception do
  begin
     ExceptionLog('Exception:'+E.Message);
  end;
end;
If an exception occurs for the above case, then the condition you have provided in the stored procedure
osmantaskiran wrote:"if (bla bla bla)
is not executed. In this case, please compose a small complete sample demonstrating the problem and send it to andreyz*devart*com . In addition, include test table and stored procedure creating scripts in the project.

Post Reply