FireDAC.Comp.Client.TFDCustomStoredProc.ExecProc

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure ExecProc; overload;
function ExecProc(const AProcName: String): LongInt; overload;
function ExecProc(const AProcName: String; const AParams: array of Variant): LongInt; overload;
function ExecProc(const AProcName: String; const AParams: array of Variant;  const ATypes: array of TFieldType): LongInt; overload;

C++

void __fastcall ExecProc()/* overload */;
int __fastcall ExecProc(const System::UnicodeString AProcName)/* overload */;
int __fastcall ExecProc(const System::UnicodeString AProcName, const System::Variant *AParams, const int AParams_High)/* overload */;
int __fastcall ExecProc(const System::UnicodeString AProcName, const System::Variant *AParams, const int AParams_High, const Data::Db::TFieldType *ATypes, const int ATypes_High)/* overload */;

Properties

Type Visibility Source Unit Parent
procedure
function
public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomStoredProc

Description

Executes the specified stored procedure in the DBMS session.

This method is overloaded:

  • The first overloaded method executes the specified stored procedure in the DBMS session.
FDStoredProc1.StoredProcName := 'myproc';
FDStoredProc1.Prepare;
FDStoredProc1.ParamByName('inval').Value := 100;
FDStoredProc1.ExecProc;
ShowMessage(FDStoredProc1.ParamByName('outval').AsString);
  • The second overloaded method executes the specified stored procedure in the DBMS session. AProcName can include an overload number specified after ';'.
FDStoredProc1.ExecProc('myproc');
  • The third overloaded method executes the specified stored function, assigns parameter values for the stored function arguments, and returns its value. AParams values are assigned to the input parameters.
FDStoredProc1.ExecProc('myproc;2', [100, 'qweqwe']);
  • The fourth overloaded method executes the specified stored function, assigns parameter data type and values for the stored proc arguments, and returns its value.
FDStoredProc1.ExecProc('myproc', [100, 'qweqwe'], [ftInteger, ftWideString]);


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, assign the stored procedure name to the CatalogName, SchemaName, PackageName, StoredProcName, Overload properties. If fiMeta is in FetchOptions.Items, then call the Prepare method. After this, the Params property will be filled by parameters. Otherwise, if fiMeta is not in FetchOptions.Items, provide a correct set of parameters in the Params property, then call the Prepare method. After this, by calling a stored procedure, the SQL statement is built and parameters are bound. 

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

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

To cancel the stored procedure execution, use TFDAdaptedDataSet.AbortJob

Before the stored procedure execution, the BeforeExecute event is fired. If the server returns a stored procedure execution error, then FireDAC raises an exception. It can be analyzed in the OnError event. After the stored procedure execution is finished, the AfterExecute event is fired.

See Also