IDASQLCommand用法(包含事务)

procedure DoLogout(const Session:TROSession; Connection:IDAConnection; ServerLog:TDAServerLog);
var
  Cmd : IDASQLCommand;
  CommandLog:TDASQLCommandLog;
  ErrorLog:TDASQLErrorLog;
begin
  if (LogoutCommand<>'')
    then Cmd := ServiceSchema.NewCommand(Connection, 'Logout', ['SessionID'],
                                         [GUIDToString(Session.SessionID)]);

  if Not Connection.InTransaction then
    Connection.BeginTransaction;
  try
    Cmd.Execute;
    Connection.CommitTransaction;

    CommandLog:=TDASQLCommandLog.Create(ServerLog, Session, Cmd, Cmd.SQL, 0);
  except
    on E:Exception do
    begin
      Connection.RollbackTransaction;

      ErrorLog:=TDASQLErrorLog.Create(ServerLog, Session, E, Cmd, Cmd.SQL);
    end;
  end;
end;

posted @ 2013-07-23 15:45  leon_kin  阅读(264)  评论(0编辑  收藏  举报