FireDAC.Comp.Client.TFDCustomStoredProc.ExecFunc
Delphi
function ExecFunc: Variant; overload;
function ExecFunc(const AProcName: String): Variant; overload;
function ExecFunc(const AProcName: String; const AParams: array of Variant): Variant; overload;
function ExecFunc(const AProcName: String; const AParams: array of Variant; const ATypes: array of TFieldType): Variant; overload;
C++
System::Variant __fastcall ExecFunc()/* overload */;
System::Variant __fastcall ExecFunc(const System::UnicodeString AProcName)/* overload */;
System::Variant __fastcall ExecFunc(const System::UnicodeString AProcName, const System::Variant *AParams, const int AParams_High)/* overload */;
System::Variant __fastcall ExecFunc(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 |
---|---|---|---|---|
function | public | FireDAC.Comp.Client.pas FireDAC.Comp.Client.hpp |
FireDAC.Comp.Client | TFDCustomStoredProc |
Description
Executes a stored function.
This method is overloaded:
- The first overloaded method executes a stored function in the DBMS session and returns its value.
var
v: Variant;
...
FDStoredProc1.StoredProcName := 'myfunc';
v := FDStoredProc1.ExecFunc;
- The second overloaded method executes the specified stored function in the DMBS session and returns its value.
AProcName
can include an overload number specified after ';'.
var
v: Variant;
...
v := FDStoredProc1.ExecFunc('myfunc');
- 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.
var
v: Variant;
...
v := FDStoredProc1.ExecFunc('myfunc;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.
var
v: Variant;
...
v := FDStoredProc1.ExecFunc('myfunc', [100, 'qweqwe'], [ftInteger, ftWideString]);
Before calling ExecFunc, assign stored function additional name parts to the CatalogName, SchemaName, PackageName, Overload properties. As part of the ExecFunc call, the SQL statement is built calling the stored procedure. Use ResourceOptions.CmdExecMode to control the asynchronous execution mode and ResourceOptions.CmdExecTimeout to set the maximum stored function execution time. After that time, the stored function execution will be canceled and an exception will be raised.
To cancel the stored function execution, use TFDAdaptedDataSet.AbortJob. Before the stored function execution, the BeforeExecute event is fired. If the server returns a stored function execution error, then FireDAC raises an exception. It can be analyzed in the OnError event. After the stored function execution is finished, the AfterExecute event is fired.