TDALocalCommand
Overview
The TDALocalCommand visual component allows to execute commands (stored procedures or SQL statements) from the Schema published by a custom service.
This class works similarly to the TDARemoteCommand class, but is designed for usage with local services only.
As an example, imagine the following scenario: In the Schema Modeler of your custom DA application, you have defined the remote data table Table1
and the command DeleteRow, which should delete the row with the specified ID from Table1
. If there are exceptions while deleting the command, error code is returned, if no exeptions are encountered (and 0 is returned), the TDALocalCommand object can be used as follows:
function DeleteRowFromTable1(aID:integer):integer;
var
lCommand:TDALocalCommand;
linp, lout: DataParameterArray;
i: integer;
begin
try
lCommand:=TDALocalCommand.Create(nil);
lCommand.ServiceName:='MyService';
linp := DataParameterArray.Create;
try
with linp.Add do begin
Name := UTF8Encode('ID');
Value := aID;
end;
lCommand.Execute('DeleteRow',linp, lout);
if lout <> nil then
for I := 0 to lout.Count - 1 do
if UTF8ToString(lout[i].Name) = 'ErrorCode' then
Result := lout[i].Value;
finally
linp.Free;
lOut.Free;
end;
finally
lCommand.Destroy;
end;
end;
In this code example, the lCommand object hooks with the local service, which contains the list of available commands, executes the command DeleteRow with the specified row ID and returns the specified error code.
Location
- Unit: uDALocalCommand.pas
- Ancestry: TComponent | TROComponent | TDABaseCommand | TDALocalCommand
constructor Create (TComponent) override (declared in TROComponent)
Standard component constructor
constructor Create(aOwner: TComponent)
Parameters:
- aOwner: Owner
constructor Create (IDataAbstractLocalServiceAccess) reintroduce overload beta
Creates a new instance and initializes the ServiceInstance property.
constructor Create(const aServiceInstance: IDataAbstractLocalServiceAccess)
Parameters:
- aServiceInstance: Data Service instance that will be used to execute the command
constructor Create (string) reintroduce overload beta
Creates a new instance and initializes the ServiceName property.
constructor Create(const aServiceName: string)
Parameters:
- aServiceName: Name of the Data Service that will be used to execute the command
Assign override
Copies the contents of another, similar object.
procedure Assign(Source: TPersistent)
Parameters:
- Source: Instance whose properties will be copied
Execute (string): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and returns the number of affected rows.
function Execute(aCommandName: string): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
Execute (string, DataParameterArray): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aInputParameters: DataParameterArray): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aInputParameters: Specified array with input parameters.
Execute (string, DataParameterArray, DataParameterArray): Integer override
Executes the command with the given name and input parameters and returns the number of affected rows and output parameters.
function Execute(aCommandName: string; aInputParameters: DataParameterArray; out aOutputParameters: DataParameterArray): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aInputParameters: Specified array with input parameters.
- aOutputParameters: Specified array with output parameters.
Execute (string, array of string, array of Variant): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aParamNames: array of string; aParamValues: array of Variant): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aParamNames: Specified array with input parameter names that will be encoded to UTF8 format.
- aParamValues: specified array with input parameter values.
Execute (string, array of Variant): Integer overload (declared in TDABaseCommand)
Executes the command with the given input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aParamValues: array of Variant): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aParamValues: specified array with input parameter values.
Notification protected override (declared in TROComponent)
Forwards notification messages to all owned components.
procedure Notification(aComponent: TComponent; Operation: TOperation)
Parameters:
- aComponent: component
- Operation: operation
ROFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure ROFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
RORemoveFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure RORemoveFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
SendRemoveNotification protected (declared in TROComponent)
Forwards notification messages to all owned components.
procedure SendRemoveNotification(aComponent: TComponent)
Parameters:
- aComponent: component
ServiceInstance
The service instance currently in use. When the ServiceName is set, this service instance will be initialized when the first call is done. You can also assign your own instance.
property ServiceInstance: IDataAbstractLocalServiceAccess read write
ServiceName
Name of the local service that holds the schema and business logic.
property ServiceName: string read write
SessionID
The client ID that the service will get while running.
property SessionID: TGuid read write
ServiceInstance
The service instance currently in use. When the ServiceName is set, this service instance will be initialized when the first call is done. You can also assign your own instance.
property ServiceInstance: IDataAbstractLocalServiceAccess read write
ServiceName
Name of the local service that holds the schema and business logic.
property ServiceName: string read write
SessionID
The client ID that the service will get while running.
property SessionID: TGuid read write
constructor Create (TComponent) override (declared in TROComponent)
Standard component constructor
constructor Create(aOwner: TComponent)
Parameters:
- aOwner: Owner
constructor Create (IDataAbstractLocalServiceAccess) reintroduce overload beta
Creates a new instance and initializes the ServiceInstance property.
constructor Create(const aServiceInstance: IDataAbstractLocalServiceAccess)
Parameters:
- aServiceInstance: Data Service instance that will be used to execute the command
constructor Create (string) reintroduce overload beta
Creates a new instance and initializes the ServiceName property.
constructor Create(const aServiceName: string)
Parameters:
- aServiceName: Name of the Data Service that will be used to execute the command
Assign override
Copies the contents of another, similar object.
procedure Assign(Source: TPersistent)
Parameters:
- Source: Instance whose properties will be copied
Execute (string): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and returns the number of affected rows.
function Execute(aCommandName: string): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
Execute (string, DataParameterArray): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aInputParameters: DataParameterArray): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aInputParameters: Specified array with input parameters.
Execute (string, DataParameterArray, DataParameterArray): Integer override
Executes the command with the given name and input parameters and returns the number of affected rows and output parameters.
function Execute(aCommandName: string; aInputParameters: DataParameterArray; out aOutputParameters: DataParameterArray): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aInputParameters: Specified array with input parameters.
- aOutputParameters: Specified array with output parameters.
Execute (string, array of string, array of Variant): Integer overload (declared in TDABaseCommand)
Executes the command with the given name and input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aParamNames: array of string; aParamValues: array of Variant): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aParamNames: Specified array with input parameter names that will be encoded to UTF8 format.
- aParamValues: specified array with input parameter values.
Execute (string, array of Variant): Integer overload (declared in TDABaseCommand)
Executes the command with the given input parameters and returns the number of affected rows.
function Execute(aCommandName: string; aParamValues: array of Variant): Integer
Parameters:
- aCommandName: Name of the command that is declared in the schema.
- aParamValues: specified array with input parameter values.
Notification protected override (declared in TROComponent)
Forwards notification messages to all owned components.
procedure Notification(aComponent: TComponent; Operation: TOperation)
Parameters:
- aComponent: component
- Operation: operation
ROFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure ROFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
RORemoveFreeNotification (declared in TROComponent)
Forwards notification messages to all owned components.
procedure RORemoveFreeNotification(aComponent: TComponent)
Parameters:
- aComponent: component
SendRemoveNotification protected (declared in TROComponent)
Forwards notification messages to all owned components.
procedure SendRemoveNotification(aComponent: TComponent)
Parameters:
- aComponent: component
- TDARemoteCommand
- IDataAbstractLocalServiceAccess