TDAEStoredProcedure

Overview

The TDAEStoredProcedure base class extends TDAEBaseStoredProcedure and adds connection support.

For an overall description, please refer to the article How to create a Data Abstract Driver (Delphi).

Location


 

constructor Create (IDAConnection, TDataset, string)  virtual    (declared in TDAESQLCommand)

Creates a new instance.

constructor Create(aConnection: IDAConnection; aDataset: TDataset; const aName: string)

Parameters:

  • aConnection: Connection
  • aDataset: Dataset
  • aName: Name

constructor Create (TDAEConnection, string)  reintroduce virtual

Creates a new instance.

constructor Create(aConnection: TDAEConnection; const aName: string)

Parameters:

  • aConnection: Connection.
  • aName: name.

CachedParams  protected    (declared in TDAESQLCommand)

property CachedParams: TDictionary<string, Integer> read

CanUseNativeFieldData  protected safecall    (declared in TDAESQLCommand)

Specifies that given field can return data in GetNativeFieldData method

function CanUseNativeFieldData(Index: Integer): Boolean

Parameters:

  • Index: Required field index

ClearParams  protected virtual    (declared in TDAESQLCommand)

Clears parameter values.

procedure ClearParams

Connection  protected    (declared in TDAESQLCommand)

Presents the IDAConnection to access information about available databases, tables, columns, etc.

property Connection: IDAConnection read

Connection  protected

Connection

property Connection: TDAEConnection read

CreateDataset  protected virtual abstract

Creates native stored procedure object

function CreateDataset(aConnection: TDAEConnection): TDataset

Parameters:

  • aConnection: owner connection

CreateNativeDatabaseAccess  protected virtual    (declared in TDAESQLCommand)

Creates an IDANativeDatabaseAccess implementor.

function CreateNativeDatabaseAccess: IDANativeDatabaseAccess

CreateNativeObject  protected virtual

Creates the native object.

function CreateNativeObject(aConnection: TDAEConnection): TObject

Parameters:

  • aConnection: connection

Dataset    (declared in TDAESQLCommand)

Access to the standard VCL TDataSet.

property Dataset: TDataset read

DoCreateNativeObject  protected override

Creates a object specific to the given connection.

function DoCreateNativeObject: TObject

DoExecute  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Executes stored procedure

function DoExecute: Integer

DoPrepare  protected virtual safecall    (declared in TDAEBaseStoredProcedure)

Empty method. Stored procedures do not need to be prepared by default.

procedure DoPrepare(Value: Boolean)

Parameters:

  • Value: not used

DynamicWhere  protected    (declared in TDAESQLCommand)

Implementation of Dynamic Where.

property DynamicWhere: TDAWhereBuilder read write

Execute  protected override safecall    (declared in TDAEBaseStoredProcedure)

Executes stored procedure

function Execute: Integer

FindCachedParameter  protected    (declared in TDAESQLCommand)

function FindCachedParameter(const AParams: TParams; const AParamName: string): TParam

Parameters:

  • AParams:
  • AParamName:

FindParameter  protected    (declared in TDAESQLCommand)

Finds the AParamName parameter in the |TParams collection.

function FindParameter(const AParams: TParams; const AParamName: string): TParam

Parameters:

  • AParams:
  • AParamName:

GetDataset  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning the result of CreateDataset.

function GetDataset: TDataset

GetName  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning a value set in the constructor.

function GetName: string

GetNativeFieldData  protected virtual safecall    (declared in TDAESQLCommand)

Sets the DataSize to the according field size value, allocates the Data memory and copies the content of the field.

function GetNativeFieldData(Index: Integer; var Buffer: TBytes): Boolean

Parameters:

  • Index: Required field index
  • Buffer:

GetNativeFieldDataType  protected safecall    (declared in TDAESQLCommand)

Returns the field type of the Index field

function GetNativeFieldDataType(Index: Integer): TFieldType

Parameters:

  • Index: field index

GetParams  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning the current parameters.

function GetParams: TDAParamCollection

GetParamValues  protected virtual safecall abstract    (declared in TDAESQLCommand)

Retrieves the values of the given parameters.

procedure GetParamValues(Params: TDAParamCollection)

Parameters:

  • Params: Parameters

GetParamValuesStd  protected    (declared in TDAESQLCommand)

Retrieves the values from Params2 for the daptOutput, daptInputOutput and daptResult parameters of Params1.

procedure GetParamValuesStd(Params1: TDAParamCollection; Params2: TParams)

Parameters:

  • Params1: Parameters guide
  • Params2: Values source

GetStoredProcedureName  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Returns the stored procedure name.

function GetStoredProcedureName: string

intVCLTypeToDAType  protected virtual    (declared in TDAESQLCommand)

Gets mapping |TFieldType to TDADataType.

function intVCLTypeToDAType(aFieldType: TFieldType; ASize: Integer; ADecimalPrecision: Integer; aDecimalScale: Integer): TDADataType

Parameters:

  • aFieldType:
  • ASize:
  • ADecimalPrecision:
  • aDecimalScale:

IsTDatasetCompatible  protected safecall    (declared in TDAESQLCommand)

Returns true if data access object is TDataset descendant.

function IsTDatasetCompatible: Boolean

Name  protected    (declared in TDAESQLCommand)

Returns a human-readable name for the command.

property Name: string read

NativeDatabaseAccess  protected    (declared in TDAESQLCommand)

property NativeDatabaseAccess: IDANativeDatabaseAccess read

NativeFieldCount  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommandNativeObject by delegating the call to the FNativeDatabaseAccess member.

function NativeFieldCount: Integer

NativeFields  protected    (declared in TDAESQLCommand)

property NativeFields[Index: Integer]: IDANativeField read

NativeFindField  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommandNativeObject by delegating the call to the FNativeDatabaseAccess member.

function NativeFindField(const FieldName: string): IDANativeField

Parameters:

  • FieldName: name of the searched field

NativeObject  protected    (declared in TDAESQLCommand)

Access to the standard VCL |TObject which implements the data access.

property NativeObject: TObject read

OnAfterExecute    (declared in TDAESQLCommand)

Fires right after a command was executed.

property OnAfterExecute: TDAAfterExecuteCommandEvent read write
delegate: procedure OnAfterExecute(const Sender: IDASQLCommand; ActualSQL: string; ElapsedMilliseconds: Cardinal)

OnBeforeExecute    (declared in TDAESQLCommand)

Fires before command execution

property OnBeforeExecute: TDABeforeExecuteCommandEvent read write
delegate: procedure OnBeforeExecute(const Sender: IDASQLCommand)

OnExecuteError    (declared in TDAESQLCommand)

Fires when exception is detected during command execution

property OnExecuteError: TDAExecuteCommandErrorEvent read write
delegate: procedure OnExecuteError(const Sender: IDASQLCommand; ActualSQL: string; Error: Exception)

ParamByName  protected safecall    (declared in TDAESQLCommand)

Locates a specific parameter, based on its name. If no matching parameter is defined, an exception will be raised.

function ParamByName(const aName: string): TDAParam

Parameters:

  • aName: name of the parameter

Params  protected    (declared in TDAESQLCommand)

Provides access to the list of parameters defined for the command.

property Params: TDAParamCollection read

Prepared  protected    (declared in TDAESQLCommand)

Specifies whether the SQL statement has been prepared for execution on the database (true) or not (false). Setting this property to true will automatically prepare the statement. Preparing statements on the database server allows for faster execution, especially if the statement will be executed multiple times, as the server will not need to re-parse the SQL text for every execution. Please refer to your database system's documentation for more information on preparing statements.

Note that changing the SQL or Where properties will automatically un-prepare the statement.

property Prepared: Boolean read write

PrepareSQLStatement  protected override    (declared in TDAEBaseStoredProcedure)

Abstract class. RefreshParams must be implemented in the descendants.

procedure PrepareSQLStatement

RecreateCachedParams  protected    (declared in TDAESQLCommand)

procedure RecreateCachedParams(aParams: TParams)

Parameters:

  • aParams:

RefreshParams  protected virtual safecall    (declared in TDAESQLCommand)

Refreshes the list of parameters defined for the command based on the actual parameter names found in the SQL statement and Where clause.

procedure RefreshParams

RefreshParamsStd  protected    (declared in TDAEBaseStoredProcedure)

Refreshes the parameters. Descendants may use it for RefreshParams.

procedure RefreshParamsStd(AParams: TParams)

Parameters:

  • AParams: Input parameters

SetParamValues  protected virtual safecall abstract    (declared in TDAESQLCommand)

Converts values from Data Abstract TDAParam values.

procedure SetParamValues(Params: TDAParamCollection)

Parameters:

  • Params: parameters

SetParamValuesStd  protected    (declared in TDAESQLCommand)

Utility method to set the values of Params2 (|TParams) for the daptOutput, daptInputOutput and daptResult parameters of Params1 (TDAParamCollection).

procedure SetParamValuesStd(Params1: TDAParamCollection; Params2: TParams)

Parameters:

  • Params1: Parameters guide
  • Params2: Values holder

SetStoredProcedureName  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Sets the stored procedure name.

procedure SetStoredProcedureName(const Name: string)

Parameters:

  • Name: Stored procedure name

SQL  protected    (declared in TDAESQLCommand)

Defines the SQL statement to be executed.

property SQL: string read write

SQLContainsDynamicWhere  protected virtual safecall    (declared in TDAESQLCommand)

Checks if SQL contains Dynamic Where macros.

function SQLContainsDynamicWhere: Boolean

StoredProcedureName  protected    (declared in TDAEBaseStoredProcedure)

Stored procedure name

property StoredProcedureName: string read write

 

CachedParams  protected    (declared in TDAESQLCommand)

property CachedParams: TDictionary<string, Integer> read

Connection  protected    (declared in TDAESQLCommand)

Presents the IDAConnection to access information about available databases, tables, columns, etc.

property Connection: IDAConnection read

Connection  protected

Connection

property Connection: TDAEConnection read

Dataset    (declared in TDAESQLCommand)

Access to the standard VCL TDataSet.

property Dataset: TDataset read

DynamicWhere  protected    (declared in TDAESQLCommand)

Implementation of Dynamic Where.

property DynamicWhere: TDAWhereBuilder read write

Name  protected    (declared in TDAESQLCommand)

Returns a human-readable name for the command.

property Name: string read

NativeDatabaseAccess  protected    (declared in TDAESQLCommand)

property NativeDatabaseAccess: IDANativeDatabaseAccess read

NativeFields  protected    (declared in TDAESQLCommand)

property NativeFields[Index: Integer]: IDANativeField read

NativeObject  protected    (declared in TDAESQLCommand)

Access to the standard VCL |TObject which implements the data access.

property NativeObject: TObject read

Params  protected    (declared in TDAESQLCommand)

Provides access to the list of parameters defined for the command.

property Params: TDAParamCollection read

Prepared  protected    (declared in TDAESQLCommand)

Specifies whether the SQL statement has been prepared for execution on the database (true) or not (false). Setting this property to true will automatically prepare the statement. Preparing statements on the database server allows for faster execution, especially if the statement will be executed multiple times, as the server will not need to re-parse the SQL text for every execution. Please refer to your database system's documentation for more information on preparing statements.

Note that changing the SQL or Where properties will automatically un-prepare the statement.

property Prepared: Boolean read write

SQL  protected    (declared in TDAESQLCommand)

Defines the SQL statement to be executed.

property SQL: string read write

StoredProcedureName  protected    (declared in TDAEBaseStoredProcedure)

Stored procedure name

property StoredProcedureName: string read write

 

constructor Create (IDAConnection, TDataset, string)  virtual    (declared in TDAESQLCommand)

Creates a new instance.

constructor Create(aConnection: IDAConnection; aDataset: TDataset; const aName: string)

Parameters:

  • aConnection: Connection
  • aDataset: Dataset
  • aName: Name

constructor Create (TDAEConnection, string)  reintroduce virtual

Creates a new instance.

constructor Create(aConnection: TDAEConnection; const aName: string)

Parameters:

  • aConnection: Connection.
  • aName: name.

CanUseNativeFieldData  protected safecall    (declared in TDAESQLCommand)

Specifies that given field can return data in GetNativeFieldData method

function CanUseNativeFieldData(Index: Integer): Boolean

Parameters:

  • Index: Required field index

ClearParams  protected virtual    (declared in TDAESQLCommand)

Clears parameter values.

procedure ClearParams

CreateDataset  protected virtual abstract

Creates native stored procedure object

function CreateDataset(aConnection: TDAEConnection): TDataset

Parameters:

  • aConnection: owner connection

CreateNativeDatabaseAccess  protected virtual    (declared in TDAESQLCommand)

Creates an IDANativeDatabaseAccess implementor.

function CreateNativeDatabaseAccess: IDANativeDatabaseAccess

CreateNativeObject  protected virtual

Creates the native object.

function CreateNativeObject(aConnection: TDAEConnection): TObject

Parameters:

  • aConnection: connection

DoCreateNativeObject  protected override

Creates a object specific to the given connection.

function DoCreateNativeObject: TObject

DoExecute  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Executes stored procedure

function DoExecute: Integer

DoPrepare  protected virtual safecall    (declared in TDAEBaseStoredProcedure)

Empty method. Stored procedures do not need to be prepared by default.

procedure DoPrepare(Value: Boolean)

Parameters:

  • Value: not used

Execute  protected override safecall    (declared in TDAEBaseStoredProcedure)

Executes stored procedure

function Execute: Integer

FindCachedParameter  protected    (declared in TDAESQLCommand)

function FindCachedParameter(const AParams: TParams; const AParamName: string): TParam

Parameters:

  • AParams:
  • AParamName:

FindParameter  protected    (declared in TDAESQLCommand)

Finds the AParamName parameter in the |TParams collection.

function FindParameter(const AParams: TParams; const AParamName: string): TParam

Parameters:

  • AParams:
  • AParamName:

GetDataset  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning the result of CreateDataset.

function GetDataset: TDataset

GetName  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning a value set in the constructor.

function GetName: string

GetNativeFieldData  protected virtual safecall    (declared in TDAESQLCommand)

Sets the DataSize to the according field size value, allocates the Data memory and copies the content of the field.

function GetNativeFieldData(Index: Integer; var Buffer: TBytes): Boolean

Parameters:

  • Index: Required field index
  • Buffer:

GetNativeFieldDataType  protected safecall    (declared in TDAESQLCommand)

Returns the field type of the Index field

function GetNativeFieldDataType(Index: Integer): TFieldType

Parameters:

  • Index: field index

GetParams  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommand by returning the current parameters.

function GetParams: TDAParamCollection

GetParamValues  protected virtual safecall abstract    (declared in TDAESQLCommand)

Retrieves the values of the given parameters.

procedure GetParamValues(Params: TDAParamCollection)

Parameters:

  • Params: Parameters

GetParamValuesStd  protected    (declared in TDAESQLCommand)

Retrieves the values from Params2 for the daptOutput, daptInputOutput and daptResult parameters of Params1.

procedure GetParamValuesStd(Params1: TDAParamCollection; Params2: TParams)

Parameters:

  • Params1: Parameters guide
  • Params2: Values source

GetStoredProcedureName  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Returns the stored procedure name.

function GetStoredProcedureName: string

intVCLTypeToDAType  protected virtual    (declared in TDAESQLCommand)

Gets mapping |TFieldType to TDADataType.

function intVCLTypeToDAType(aFieldType: TFieldType; ASize: Integer; ADecimalPrecision: Integer; aDecimalScale: Integer): TDADataType

Parameters:

  • aFieldType:
  • ASize:
  • ADecimalPrecision:
  • aDecimalScale:

IsTDatasetCompatible  protected safecall    (declared in TDAESQLCommand)

Returns true if data access object is TDataset descendant.

function IsTDatasetCompatible: Boolean

NativeFieldCount  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommandNativeObject by delegating the call to the FNativeDatabaseAccess member.

function NativeFieldCount: Integer

NativeFindField  protected safecall    (declared in TDAESQLCommand)

Implements IDASQLCommandNativeObject by delegating the call to the FNativeDatabaseAccess member.

function NativeFindField(const FieldName: string): IDANativeField

Parameters:

  • FieldName: name of the searched field

ParamByName  protected safecall    (declared in TDAESQLCommand)

Locates a specific parameter, based on its name. If no matching parameter is defined, an exception will be raised.

function ParamByName(const aName: string): TDAParam

Parameters:

  • aName: name of the parameter

PrepareSQLStatement  protected override    (declared in TDAEBaseStoredProcedure)

Abstract class. RefreshParams must be implemented in the descendants.

procedure PrepareSQLStatement

RecreateCachedParams  protected    (declared in TDAESQLCommand)

procedure RecreateCachedParams(aParams: TParams)

Parameters:

  • aParams:

RefreshParams  protected virtual safecall    (declared in TDAESQLCommand)

Refreshes the list of parameters defined for the command based on the actual parameter names found in the SQL statement and Where clause.

procedure RefreshParams

RefreshParamsStd  protected    (declared in TDAEBaseStoredProcedure)

Refreshes the parameters. Descendants may use it for RefreshParams.

procedure RefreshParamsStd(AParams: TParams)

Parameters:

  • AParams: Input parameters

SetParamValues  protected virtual safecall abstract    (declared in TDAESQLCommand)

Converts values from Data Abstract TDAParam values.

procedure SetParamValues(Params: TDAParamCollection)

Parameters:

  • Params: parameters

SetParamValuesStd  protected    (declared in TDAESQLCommand)

Utility method to set the values of Params2 (|TParams) for the daptOutput, daptInputOutput and daptResult parameters of Params1 (TDAParamCollection).

procedure SetParamValuesStd(Params1: TDAParamCollection; Params2: TParams)

Parameters:

  • Params1: Parameters guide
  • Params2: Values holder

SetStoredProcedureName  protected virtual safecall abstract    (declared in TDAEBaseStoredProcedure)

Sets the stored procedure name.

procedure SetStoredProcedureName(const Name: string)

Parameters:

  • Name: Stored procedure name

SQLContainsDynamicWhere  protected virtual safecall    (declared in TDAESQLCommand)

Checks if SQL contains Dynamic Where macros.

function SQLContainsDynamicWhere: Boolean

 

OnAfterExecute    (declared in TDAESQLCommand)

Fires right after a command was executed.

property OnAfterExecute: TDAAfterExecuteCommandEvent read write
delegate: procedure OnAfterExecute(const Sender: IDASQLCommand; ActualSQL: string; ElapsedMilliseconds: Cardinal)

OnBeforeExecute    (declared in TDAESQLCommand)

Fires before command execution

property OnBeforeExecute: TDABeforeExecuteCommandEvent read write
delegate: procedure OnBeforeExecute(const Sender: IDASQLCommand)

OnExecuteError    (declared in TDAESQLCommand)

Fires when exception is detected during command execution

property OnExecuteError: TDAExecuteCommandErrorEvent read write
delegate: procedure OnExecuteError(const Sender: IDASQLCommand; ActualSQL: string; Error: Exception)