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

 

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

constructor Create (TComponent)  override    (declared in TROComponent)

Creates a new instance.

constructor Create(AOwner: TComponent)

Parameters:

  • AOwner: Owner.

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, 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, 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.

ROFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned RO components.

procedure ROFreeNotification(AComponent: TComponent)

Parameters:

  • AComponent: component

RORemoveFreeNotification    (declared in TROComponent)

Disables destruction notification for specified RO component.

procedure RORemoveFreeNotification(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 (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

constructor Create (TComponent)  override    (declared in TROComponent)

Creates a new instance.

constructor Create(AOwner: TComponent)

Parameters:

  • AOwner: Owner.

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, 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, 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.

ROFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned RO components.

procedure ROFreeNotification(AComponent: TComponent)

Parameters:

  • AComponent: component

RORemoveFreeNotification    (declared in TROComponent)

Disables destruction notification for specified RO component.

procedure RORemoveFreeNotification(AComponent: TComponent)

Parameters:

  • AComponent: component

See Also