Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread Generic Server-Side SQL Processor
Tue, May 2 2006 1:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Here is a generic server-side SQL processor for executing large scripts that
don't return result sets.  It could handle result sets with the addition of
another return parameter for saving the result set stream back to the client
via a parameter.  Also, it could be improved to send back query progress
information via the TDBISAMSession.SendProcedureProgress method.

You can call this procedure using a remote session like this:

with MyRemoteSession do
  begin
   with RemoteParams do
     begin
     CreateParam(ftString,'DatabaseName').AsString:='MyDatabase';
     CreateParam(ftString,'SQL').AsString:=MySQLScript;
     CallRemoteProcedure('ServerSideSQLProcessor');
     end;
  end;

Also, be sure to set up the proper rights, etc. for the server-side
procedure using the Server Administration Utility or the TDBISAMSession
administrative methods.

procedure TForm1.DBISAMEngineServerProcedure(Sender: TObject;
 ServerSession: TDBISAMSession; const ProcedureName: String);
var
  TempQuery: TDBISAMQuery;
  TempDescription: string;
  TempPath: string;
begin
  if AnsiSameText(ProcedureName,'ServerSideSQLProcessor') then
     begin
     TempQuery:=TDBISAMQuery.Create(nil);
     try
        with ServerSession do
           begin
           Engine.GetServerDatabase(RemoteParams.ParamByName('DatabaseName'),
                                                     TempDescription,TempPath);
           with TempQuery do
              begin
              SessionName:=ServerSession.SessionName;
              DatabaseName:=TempPath;
              SQL.Text:=RemoteParams.ParamByName('SQL').AsString;
              ExecSQL;
              RemoteParams.Clear;
              RemoteParams.CreateParam(ftInteger,'RowsAffected').AsInteger:=RowsAffected;
              end;
           end;
     finally
        TempQuery.Free;
     end;
     end;
end;

--
Tim Young
Elevate Software
www.elevatesoft.com

Image