首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

IDASQLCommand用法(包含事务)

Posted on 2011-08-09 14:49  colincode  阅读(586)  评论(0编辑  收藏  举报
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;