Page 1 of 1

StoredProc Firemonkey Exception Handling

Posted: Sun 15 Mar 2015 22:56
by osmantaskiran
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;

Re: StoredProc Firemonkey Exception Handling

Posted: Wed 18 Mar 2015 11:36
by azyk
Unfortunately, we can't reproduce the described problem. Please provide the script for creating the spSampleProc stored procedure, which reproduces the issue.

Re: StoredProc Firemonkey Exception Handling

Posted: Wed 18 Mar 2015 12:46
by osmantaskiran
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.

Re: StoredProc Firemonkey Exception Handling

Posted: Fri 20 Mar 2015 11:45
by azyk
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.