TAstaServerSocket.OnStoredProcedure
Applies to
TAstaServerSocket
Declaration
type TAstaServerStoredProcEvent = procedure(Sender:
TObject;
ClientSocket:TCustomWinSocket;AQuery: TComponent;
DataBaseStr, StoredProcName: string;
ClientParams: TAstaParamList;NoResultSet:Boolean) of
object;
property OnStoredProcedure: TAstaServerStoredProcEvent
Description
This event must be coded to support StoredProcedures using ASTA. The client will send in the StoredProcName
and a TAstaParamList that will contain the parameters for the stored procedure. If parameters are to be
returned, the the ClientParams must be updated. Note the NoResultSet:Boolean which is required for StoredProcedures
that do not return a result set. The AstaClientDataSet must call ExecSQL
when invoking StoredProcedures to that do not return a result set.
See Coding ASTA Servers for steps to create an ASTAServer.
The following is an example from the AstaBDEServer showing how this method can be coded.
procedure
TForm1.AstaServerSocket1StoredProcedure(Sender: TObject;
ClientSocket: TCustomWinSocket; AQuery: TComponent; DataBaseStr,
StoredProcName: string;
ClientParams: TAstaParamList;NoResultSet:Boolean);
var
I: Integer;
P: TParam;
begin
try
if
TStoredProc(Aquery).Active then
TStoredProc(AQuery).Active :=
False;
for i := 0 to ClientParams.Count - 1 do
TStoredProc(AQuery).ParambyName(ClientParams[i].Name).Value
:=
ClientParams[i].Value;
//TStoredProc(AQuery).Prepare; prepare is now called
in the
//setup stored proc call
if NoResultSet then TStoredProc(Aquery).ExecProc else TStoredProc(AQuery).Active:=True;
ClientParams.Clear;
for i := 0 to TStoredProc(AQuery).Params.Count - 1 do begin
case TStoredProc(AQuery).Params[i].ParamType of
db.ptOutPut,
db.ptInputOutput,
db.ptResult:
begin
if ClientParams.FindParam(TStoredProc(Aquery).Params[i].
Name) = nil
then
ClientParams.CreateParam(TStoredProc(AQuery).Params[i].
DataType,
TStoredProc(AQuery).Params[i].Name,
TAstaParamType(ord(TStoredProc(AQuery).Params[i].
ParamType)));
ClientParams.ParamByName(TStoredProc(AQuery).Params[i].
Name).Value :=
TStoredProc(AQuery).Params[i].Value;
end;
end;
end;
except
LogException(ClientSocket, Exception(ExceptObject).Message, True);
end;
end;