AnyDAC
ContentsIndexHome
PreviousUpNext
TADCustomStoredProc.ExecProc Method ()

Executes the specified stored procedure in the DBMS session.

Group
Links

Call ExecProc to execute a stored procedure in the DBMS session, using the currently assigned stored procedure name. Use ExecProc to execute stored procedures, that do not return a cursor to data. 

Before calling ExecProc, assing stored procedure name to the CatalogName, SchemaName, PackageName, StoredProcName, Overload properties. Then if fiMeta in FetchOptions.Items, then call Prepare method. After that Params property will be filled by parameters. Otherwise, if fiMeta is not in FetchOptions.Items, provide correct set of parameters in the Params property, then call Prepare method. After that SQL statement, calling stored procedure, is built and parameters are binded. 

Then assign values to the input parameters and call ExecProc. After return from ExecProc you can read output parameter values. 

Use ResourceOptions.CmdExecMode to control asynchronous execution mode. And ResourceOptions.CmdExecTimeout to set maximum stored procedure execution time. After that time stored procedure execution will be canceled and exception raised. 

To cancel stored procedure execution use TADAdaptedDataSet.AbortJob

Before stored procedure execution the BeforeExecute event is fired. If server will return stored procedure execution error, then AnyDAC raises an exception. It may be analyzed in OnError event. After stored procedure execution is finished, AfterExecute event is fired.

procedure ExecProc; overload;
ADStoredProc1.StoredProcName := 'myproc';
ADStoredProc1.Prepare;
ADStoredProc1.ParamByName('inval').Value := 100;
ADStoredProc1.ExecProc;
ShowMessage(ADStoredProc1.ParamByName('outval').AsString);
What do you think about this topic? Send feedback!