mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 20:50:30 +02:00
fcl-db: sqldb: rename some of new types as discussed in DB-Core
git-svn-id: trunk@29143 -
This commit is contained in:
parent
a77243f507
commit
9f730c9831
@ -24,13 +24,7 @@ uses SysUtils, Classes, DB, bufdataset, sqlscript;
|
|||||||
|
|
||||||
type
|
type
|
||||||
TSchemaType = (stNoSchema, stTables, stSysTables, stProcedures, stColumns, stProcedureParams, stIndexes, stPackages, stSchemata);
|
TSchemaType = (stNoSchema, stTables, stSysTables, stProcedures, stColumns, stProcedureParams, stIndexes, stPackages, stSchemata);
|
||||||
TConnOption = (sqSupportParams, sqSupportEmptyDatabaseName, sqEscapeSlash, sqEscapeRepeat, sqImplicitTransaction);
|
|
||||||
TConnOptions= set of TConnOption;
|
|
||||||
|
|
||||||
TConnectionOption = (coExplicitConnect,coCheckRowsAffected);
|
|
||||||
TConnectionOptions = Set of TConnectionOption;
|
|
||||||
|
|
||||||
TConnInfoType=(citAll=-1, citServerType, citServerVersion, citServerVersionString, citClientName, citClientVersion);
|
|
||||||
TStatementType = (stUnknown, stSelect, stInsert, stUpdate, stDelete,
|
TStatementType = (stUnknown, stSelect, stInsert, stUpdate, stDelete,
|
||||||
stDDL, stGetSegment, stPutSegment, stExecProcedure,
|
stDDL, stGetSegment, stPutSegment, stExecProcedure,
|
||||||
stStartTrans, stCommit, stRollback, stSelectForUpd);
|
stStartTrans, stCommit, stRollback, stSelectForUpd);
|
||||||
@ -47,7 +41,6 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
type
|
|
||||||
TSQLConnection = class;
|
TSQLConnection = class;
|
||||||
TSQLTransaction = class;
|
TSQLTransaction = class;
|
||||||
TCustomSQLQuery = class;
|
TCustomSQLQuery = class;
|
||||||
@ -60,9 +53,6 @@ type
|
|||||||
TDBEventTypes = set of TDBEventType;
|
TDBEventTypes = set of TDBEventType;
|
||||||
TDBLogNotifyEvent = Procedure (Sender : TSQLConnection; EventType : TDBEventType; Const Msg : String) of object;
|
TDBLogNotifyEvent = Procedure (Sender : TSQLConnection; EventType : TDBEventType; Const Msg : String) of object;
|
||||||
|
|
||||||
TSQLQueryOption = (sqoDisconnected, sqoAutoApplyUpdates, sqoAutoCommit);
|
|
||||||
TSQLQueryOptions = Set of TSQLQueryOption;
|
|
||||||
|
|
||||||
TSQLHandle = Class(TObject)
|
TSQLHandle = Class(TObject)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -150,10 +140,18 @@ type
|
|||||||
|
|
||||||
{ TSQLConnection }
|
{ TSQLConnection }
|
||||||
|
|
||||||
|
TConnOption = (sqSupportParams, sqSupportEmptyDatabaseName, sqEscapeSlash, sqEscapeRepeat, sqImplicitTransaction);
|
||||||
|
TConnOptions= set of TConnOption;
|
||||||
|
|
||||||
|
TSQLConnectionOption = (scoExplicitConnect, scoApplyUpdatesChecksRowsAffected);
|
||||||
|
TSQLConnectionOptions = Set of TSQLConnectionOption;
|
||||||
|
|
||||||
|
TConnInfoType=(citAll=-1, citServerType, citServerVersion, citServerVersionString, citClientName, citClientVersion);
|
||||||
|
|
||||||
TSQLConnection = class (TDatabase)
|
TSQLConnection = class (TDatabase)
|
||||||
private
|
private
|
||||||
FFieldNameQuoteChars : TQuoteChars;
|
FFieldNameQuoteChars : TQuoteChars;
|
||||||
FOptions: TConnectionOptions;
|
FOptions : TSQLConnectionOptions;
|
||||||
FPassword : string;
|
FPassword : string;
|
||||||
FTransaction : TSQLTransaction;
|
FTransaction : TSQLTransaction;
|
||||||
FUserName : string;
|
FUserName : string;
|
||||||
@ -165,7 +163,7 @@ type
|
|||||||
FOnLog: TDBLogNotifyEvent;
|
FOnLog: TDBLogNotifyEvent;
|
||||||
FInternalTransaction : TSQLTransaction;
|
FInternalTransaction : TSQLTransaction;
|
||||||
function GetPort: cardinal;
|
function GetPort: cardinal;
|
||||||
procedure SetOptions(AValue: TConnectionOptions);
|
procedure SetOptions(AValue: TSQLConnectionOptions);
|
||||||
procedure SetPort(const AValue: cardinal);
|
procedure SetPort(const AValue: cardinal);
|
||||||
protected
|
protected
|
||||||
FConnOptions : TConnOptions;
|
FConnOptions : TConnOptions;
|
||||||
@ -249,9 +247,9 @@ type
|
|||||||
property HostName : string Read FHostName Write FHostName;
|
property HostName : string Read FHostName Write FHostName;
|
||||||
Property OnLog : TDBLogNotifyEvent Read FOnLog Write FOnLog;
|
Property OnLog : TDBLogNotifyEvent Read FOnLog Write FOnLog;
|
||||||
Property LogEvents : TDBEventTypes Read FLogEvents Write FLogEvents Default LogAllEvents;
|
Property LogEvents : TDBEventTypes Read FLogEvents Write FLogEvents Default LogAllEvents;
|
||||||
Property Options : TConnectionOptions Read FOptions Write SetOptions;
|
Property Options : TSQLConnectionOptions Read FOptions Write SetOptions;
|
||||||
property Connected;
|
|
||||||
Property Role : String read FRole write FRole;
|
Property Role : String read FRole write FRole;
|
||||||
|
property Connected;
|
||||||
property DatabaseName;
|
property DatabaseName;
|
||||||
property KeepConnection;
|
property KeepConnection;
|
||||||
property LoginPrompt;
|
property LoginPrompt;
|
||||||
@ -263,17 +261,18 @@ type
|
|||||||
|
|
||||||
TCommitRollbackAction = (caNone, caCommit, caCommitRetaining, caRollback,
|
TCommitRollbackAction = (caNone, caCommit, caCommitRetaining, caRollback,
|
||||||
caRollbackRetaining);
|
caRollbackRetaining);
|
||||||
TTransactionOption = (toUseImplicit, toExplicitStart);
|
|
||||||
TTransactionOptions = Set of TTransactionOption;
|
TSQLTransactionOption = (stoUseImplicit, stoExplicitStart);
|
||||||
|
TSQLTransactionOptions = Set of TSQLTransactionOption;
|
||||||
|
|
||||||
TSQLTransaction = class (TDBTransaction)
|
TSQLTransaction = class (TDBTransaction)
|
||||||
private
|
private
|
||||||
FOptions: TTransactionOptions;
|
FOptions : TSQLTransactionOptions;
|
||||||
FTrans : TSQLHandle;
|
FTrans : TSQLHandle;
|
||||||
FAction : TCommitRollbackAction;
|
FAction : TCommitRollbackAction;
|
||||||
FParams : TStringList;
|
FParams : TStringList;
|
||||||
function GetSQLConnection: TSQLConnection;
|
function GetSQLConnection: TSQLConnection;
|
||||||
procedure SetOptions(AValue: TTransactionOptions);
|
procedure SetOptions(AValue: TSQLTransactionOptions);
|
||||||
procedure SetParams(const AValue: TStringList);
|
procedure SetParams(const AValue: TStringList);
|
||||||
procedure SetSQLConnection(AValue: TSQLConnection);
|
procedure SetSQLConnection(AValue: TSQLConnection);
|
||||||
protected
|
protected
|
||||||
@ -298,7 +297,7 @@ type
|
|||||||
property Action : TCommitRollbackAction read FAction write FAction Default caRollBack;
|
property Action : TCommitRollbackAction read FAction write FAction Default caRollBack;
|
||||||
property Database;
|
property Database;
|
||||||
property Params : TStringList read FParams write SetParams;
|
property Params : TStringList read FParams write SetParams;
|
||||||
Property Options : TTransactionOptions Read FOptions Write SetOptions;
|
Property Options : TSQLTransactionOptions Read FOptions Write SetOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -375,9 +374,12 @@ type
|
|||||||
|
|
||||||
{ TCustomSQLQuery }
|
{ TCustomSQLQuery }
|
||||||
|
|
||||||
|
TSQLQueryOption = (sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit);
|
||||||
|
TSQLQueryOptions = Set of TSQLQueryOption;
|
||||||
|
|
||||||
TCustomSQLQuery = class (TCustomBufDataset)
|
TCustomSQLQuery = class (TCustomBufDataset)
|
||||||
private
|
private
|
||||||
FQueryOptions: TSQLQueryOptions;
|
FOptions : TSQLQueryOptions;
|
||||||
FSchemaType : TSchemaType;
|
FSchemaType : TSchemaType;
|
||||||
FUpdateable : boolean;
|
FUpdateable : boolean;
|
||||||
FTableName : string;
|
FTableName : string;
|
||||||
@ -412,8 +414,8 @@ type
|
|||||||
function GetSQLConnection: TSQLConnection;
|
function GetSQLConnection: TSQLConnection;
|
||||||
function GetSQLTransaction: TSQLTransaction;
|
function GetSQLTransaction: TSQLTransaction;
|
||||||
function GetStatementType : TStatementType;
|
function GetStatementType : TStatementType;
|
||||||
|
procedure SetOptions(AValue: TSQLQueryOptions);
|
||||||
procedure SetParamCheck(AValue: Boolean);
|
procedure SetParamCheck(AValue: Boolean);
|
||||||
procedure SetQueryOptions(AValue: TSQLQueryOptions);
|
|
||||||
procedure SetSQLConnection(AValue: TSQLConnection);
|
procedure SetSQLConnection(AValue: TSQLConnection);
|
||||||
procedure SetSQLTransaction(AValue: TSQLTransaction);
|
procedure SetSQLTransaction(AValue: TSQLTransaction);
|
||||||
procedure SetUpdateSQL(const AValue: TStringlist);
|
procedure SetUpdateSQL(const AValue: TStringlist);
|
||||||
@ -504,15 +506,15 @@ type
|
|||||||
property OnNewRecord;
|
property OnNewRecord;
|
||||||
property OnPostError;
|
property OnPostError;
|
||||||
property AutoCalcFields;
|
property AutoCalcFields;
|
||||||
|
// protected
|
||||||
property Database;
|
property Database;
|
||||||
// protected
|
|
||||||
Property QueryOptions : TSQLQueryOptions Read FQueryOptions Write SetQueryOptions;
|
|
||||||
property SchemaType : TSchemaType read FSchemaType default stNoSchema;
|
|
||||||
property Transaction;
|
property Transaction;
|
||||||
|
property SchemaType : TSchemaType read FSchemaType default stNoSchema;
|
||||||
property SQL : TStringlist read GetSQL write SetSQL;
|
property SQL : TStringlist read GetSQL write SetSQL;
|
||||||
property UpdateSQL : TStringlist read FUpdateSQL write SetUpdateSQL;
|
property UpdateSQL : TStringlist read FUpdateSQL write SetUpdateSQL;
|
||||||
property InsertSQL : TStringlist read FInsertSQL write SetInsertSQL;
|
property InsertSQL : TStringlist read FInsertSQL write SetInsertSQL;
|
||||||
property DeleteSQL : TStringlist read FDeleteSQL write SetDeleteSQL;
|
property DeleteSQL : TStringlist read FDeleteSQL write SetDeleteSQL;
|
||||||
|
Property Options : TSQLQueryOptions Read FOptions Write SetOptions;
|
||||||
property Params : TParams read GetParams Write SetParams;
|
property Params : TParams read GetParams Write SetParams;
|
||||||
Property ParamCheck : Boolean Read GetParamCheck Write SetParamCheck default true;
|
Property ParamCheck : Boolean Read GetParamCheck Write SetParamCheck default true;
|
||||||
property ParseSQL : Boolean read GetParseSQL write SetParseSQL default true;
|
property ParseSQL : Boolean read GetParseSQL write SetParseSQL default true;
|
||||||
@ -562,7 +564,6 @@ type
|
|||||||
Property OnPostError;
|
Property OnPostError;
|
||||||
|
|
||||||
// property SchemaInfo default stNoSchema;
|
// property SchemaInfo default stNoSchema;
|
||||||
Property QueryOptions;
|
|
||||||
property Database;
|
property Database;
|
||||||
property Transaction;
|
property Transaction;
|
||||||
property ReadOnly;
|
property ReadOnly;
|
||||||
@ -571,6 +572,7 @@ type
|
|||||||
property InsertSQL;
|
property InsertSQL;
|
||||||
property DeleteSQL;
|
property DeleteSQL;
|
||||||
property IndexDefs;
|
property IndexDefs;
|
||||||
|
Property Options;
|
||||||
property Params;
|
property Params;
|
||||||
Property ParamCheck;
|
Property ParamCheck;
|
||||||
property ParseSQL;
|
property ParseSQL;
|
||||||
@ -1182,7 +1184,7 @@ begin
|
|||||||
DatabaseError(SErrTransactionnSet);
|
DatabaseError(SErrTransactionnSet);
|
||||||
|
|
||||||
if not Connected then Open;
|
if not Connected then Open;
|
||||||
if not (ATransaction.Active or (toUseImplicit in ATransaction.Options)) then
|
if not (ATransaction.Active or (stoUseImplicit in ATransaction.Options)) then
|
||||||
ATransaction.MaybeStartTransaction;
|
ATransaction.MaybeStartTransaction;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1209,7 +1211,7 @@ begin
|
|||||||
result := StrToIntDef(Params.Values['Port'],0);
|
result := StrToIntDef(Params.Values['Port'],0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLConnection.SetOptions(AValue: TConnectionOptions);
|
procedure TSQLConnection.SetOptions(AValue: TSQLConnectionOptions);
|
||||||
begin
|
begin
|
||||||
if FOptions=AValue then Exit;
|
if FOptions=AValue then Exit;
|
||||||
FOptions:=AValue;
|
FOptions:=AValue;
|
||||||
@ -1687,15 +1689,15 @@ begin
|
|||||||
begin
|
begin
|
||||||
P:=Qry.Params[x];
|
P:=Qry.Params[x];
|
||||||
S:=p.name;
|
S:=p.name;
|
||||||
B:=Sametext(leftstr(S,4),'OLD_');
|
B:=SameText(leftstr(S,4),'OLD_');
|
||||||
if B then
|
if B then
|
||||||
Delete(S,1,4);
|
Delete(S,1,4);
|
||||||
Fld:=Query.FieldByName(S);
|
Fld:=Query.FieldByName(S);
|
||||||
ApplyFieldUpdate(Query.Cursor,P as TSQLDBParam,Fld,B);
|
ApplyFieldUpdate(Query.Cursor,P as TSQLDBParam,Fld,B);
|
||||||
end;
|
end;
|
||||||
Qry.execute;
|
Qry.Execute;
|
||||||
if (coCheckRowsAffected in Options) and (Qry.RowsAffected<>1) then
|
if (scoApplyUpdatesChecksRowsAffected in Options) and (Qry.RowsAffected<>1) then
|
||||||
DatabaseErrorFmt(SErrFailedToUpdateRecord,[Qry.RowsAffected],Query);
|
DatabaseErrorFmt(SErrFailedToUpdateRecord, [Qry.RowsAffected], Query);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLConnection.FreeFldBuffers(cursor: TSQLCursor);
|
procedure TSQLConnection.FreeFldBuffers(cursor: TSQLCursor);
|
||||||
@ -1723,7 +1725,7 @@ Procedure TSQLConnection.MaybeConnect;
|
|||||||
begin
|
begin
|
||||||
If Not Connected then
|
If Not Connected then
|
||||||
begin
|
begin
|
||||||
If (coExplicitConnect in Options) then
|
If (scoExplicitConnect in Options) then
|
||||||
DatabaseErrorFmt(SErrImplicitConnect,[Name]);
|
DatabaseErrorFmt(SErrImplicitConnect,[Name]);
|
||||||
Connected:=True;
|
Connected:=True;
|
||||||
end;
|
end;
|
||||||
@ -1751,7 +1753,7 @@ begin
|
|||||||
Commit;
|
Commit;
|
||||||
caNone,
|
caNone,
|
||||||
caRollback, caRollbackRetaining :
|
caRollback, caRollbackRetaining :
|
||||||
if not (toUseImplicit in Options) then
|
if not (stoUseImplicit in Options) then
|
||||||
RollBack
|
RollBack
|
||||||
else
|
else
|
||||||
CloseTrans;
|
CloseTrans;
|
||||||
@ -1768,11 +1770,11 @@ begin
|
|||||||
Result:=Database as TSQLConnection;
|
Result:=Database as TSQLConnection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLTransaction.SetOptions(AValue: TTransactionOptions);
|
procedure TSQLTransaction.SetOptions(AValue: TSQLTransactionOptions);
|
||||||
begin
|
begin
|
||||||
if FOptions=AValue then Exit;
|
if FOptions=AValue then Exit;
|
||||||
if (toUseImplicit in Avalue) and Assigned(SQLConnection) And Not (sqImplicitTransaction in SQLConnection.ConnOptions) then
|
if (stoUseImplicit in Avalue) and Assigned(SQLConnection) And Not (sqImplicitTransaction in SQLConnection.ConnOptions) then
|
||||||
DatabaseErrorFmt(SErrNoImplicitTransaction,[SQLConnection.ClassName]);
|
DatabaseErrorFmt(SErrNoImplicitTransaction, [SQLConnection.ClassName]);
|
||||||
FOptions:=AValue;
|
FOptions:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1785,8 +1787,8 @@ Procedure TSQLTransaction.MaybeStartTransaction;
|
|||||||
begin
|
begin
|
||||||
if not Active then
|
if not Active then
|
||||||
begin
|
begin
|
||||||
if (toExplicitStart in Options) then
|
if (stoExplicitStart in Options) then
|
||||||
DatabaseErrorFmt(SErrImplictTransactionStart,[Database.Name,Name]);
|
DatabaseErrorFmt(SErrImplictTransactionStart, [Database.Name,Name]);
|
||||||
StartTransaction;
|
StartTransaction;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1799,7 +1801,7 @@ end;
|
|||||||
Function TSQLTransaction.AllowClose(DS: TDBDataset): Boolean;
|
Function TSQLTransaction.AllowClose(DS: TDBDataset): Boolean;
|
||||||
begin
|
begin
|
||||||
if (DS is TSQLQuery) then
|
if (DS is TSQLQuery) then
|
||||||
Result:=not (sqoDisconnected in TSQLQuery(DS).QueryOptions)
|
Result:=not (sqoKeepOpenOnCommit in TSQLQuery(DS).Options)
|
||||||
else
|
else
|
||||||
Result:=Inherited AllowClose(DS);
|
Result:=Inherited AllowClose(DS);
|
||||||
end;
|
end;
|
||||||
@ -1811,7 +1813,7 @@ begin
|
|||||||
CloseDataSets;
|
CloseDataSets;
|
||||||
If LogEvent(detCommit) then
|
If LogEvent(detCommit) then
|
||||||
Log(detCommit,SCommitting);
|
Log(detCommit,SCommitting);
|
||||||
if (toUseImplicit in Options) or SQLConnection.Commit(FTrans) then
|
if (stoUseImplicit in Options) or SQLConnection.Commit(FTrans) then
|
||||||
begin
|
begin
|
||||||
CloseTrans;
|
CloseTrans;
|
||||||
FreeAndNil(FTrans);
|
FreeAndNil(FTrans);
|
||||||
@ -1833,7 +1835,7 @@ procedure TSQLTransaction.Rollback;
|
|||||||
begin
|
begin
|
||||||
if Active then
|
if Active then
|
||||||
begin
|
begin
|
||||||
if (toUseImplicit in Options) then
|
if (stoUseImplicit in Options) then
|
||||||
DatabaseError(SErrImplicitNoRollBack);
|
DatabaseError(SErrImplicitNoRollBack);
|
||||||
CloseDataSets;
|
CloseDataSets;
|
||||||
If LogEvent(detRollback) then
|
If LogEvent(detRollback) then
|
||||||
@ -1850,7 +1852,7 @@ procedure TSQLTransaction.RollbackRetaining;
|
|||||||
begin
|
begin
|
||||||
if Active then
|
if Active then
|
||||||
begin
|
begin
|
||||||
if (toUseImplicit in Options) then
|
if (stoUseImplicit in Options) then
|
||||||
DatabaseError(SErrImplicitNoRollBack);
|
DatabaseError(SErrImplicitNoRollBack);
|
||||||
If LogEvent(detRollback) then
|
If LogEvent(detRollback) then
|
||||||
Log(detRollback,SRollBackRetaining);
|
Log(detRollback,SRollBackRetaining);
|
||||||
@ -1875,7 +1877,7 @@ begin
|
|||||||
|
|
||||||
if not assigned(FTrans) then FTrans := Db.AllocateTransactionHandle;
|
if not assigned(FTrans) then FTrans := Db.AllocateTransactionHandle;
|
||||||
|
|
||||||
if (toUseImplicit in Options) then
|
if (stoUseImplicit in Options) then
|
||||||
begin
|
begin
|
||||||
if Db.StartImplicitTransaction(FTrans,FParams.CommaText) then
|
if Db.StartImplicitTransaction(FTrans,FParams.CommaText) then
|
||||||
OpenTrans
|
OpenTrans
|
||||||
@ -1910,7 +1912,7 @@ begin
|
|||||||
if Assigned(Value) and not (Value is TSQLConnection) then
|
if Assigned(Value) and not (Value is TSQLConnection) then
|
||||||
DatabaseErrorFmt(SErrNotASQLConnection,[value.Name],self);
|
DatabaseErrorFmt(SErrNotASQLConnection,[value.Name],self);
|
||||||
CheckInactive;
|
CheckInactive;
|
||||||
if (toUseImplicit in Options) and Assigned(Value) and Not (sqImplicitTransaction in TSQLConnection(Value).ConnOptions) then
|
if (stoUseImplicit in Options) and Assigned(Value) and Not (sqImplicitTransaction in TSQLConnection(Value).ConnOptions) then
|
||||||
DatabaseErrorFmt(SErrNoImplicitTransaction,[Value.ClassName]);
|
DatabaseErrorFmt(SErrNoImplicitTransaction,[Value.ClassName]);
|
||||||
If Assigned(Database) then
|
If Assigned(Database) then
|
||||||
begin
|
begin
|
||||||
@ -2075,7 +2077,7 @@ end;
|
|||||||
Procedure TCustomSQLQuery.ApplyUpdates(MaxErrors: Integer);
|
Procedure TCustomSQLQuery.ApplyUpdates(MaxErrors: Integer);
|
||||||
begin
|
begin
|
||||||
inherited ApplyUpdates(MaxErrors);
|
inherited ApplyUpdates(MaxErrors);
|
||||||
If sqoAutoCommit in QueryOptions then
|
If sqoAutoCommit in Options then
|
||||||
begin
|
begin
|
||||||
// Retrieve rows affected for last update.
|
// Retrieve rows affected for last update.
|
||||||
FStatement.RowsAffected;
|
FStatement.RowsAffected;
|
||||||
@ -2258,7 +2260,7 @@ end;
|
|||||||
procedure TCustomSQLQuery.SetPacketRecords(aValue: integer);
|
procedure TCustomSQLQuery.SetPacketRecords(aValue: integer);
|
||||||
begin
|
begin
|
||||||
if (AValue=PacketRecords) then exit;
|
if (AValue=PacketRecords) then exit;
|
||||||
if (AValue<>-1) and (sqoDisconnected in QueryOptions) then
|
if (AValue<>-1) and (sqoKeepOpenOnCommit in Options) then
|
||||||
DatabaseError(SErrDisconnectedPacketRecords);
|
DatabaseError(SErrDisconnectedPacketRecords);
|
||||||
Inherited SetPacketRecords(aValue);
|
Inherited SetPacketRecords(aValue);
|
||||||
end;
|
end;
|
||||||
@ -2417,7 +2419,7 @@ begin
|
|||||||
try
|
try
|
||||||
Prepare;
|
Prepare;
|
||||||
Execute;
|
Execute;
|
||||||
If sqoAutoCommit in QueryOptions then
|
If sqoAutoCommit in Options then
|
||||||
begin
|
begin
|
||||||
// Retrieve rows affected
|
// Retrieve rows affected
|
||||||
FStatement.RowsAffected;
|
FStatement.RowsAffected;
|
||||||
@ -2434,14 +2436,14 @@ end;
|
|||||||
Procedure TCustomSQLQuery.Post;
|
Procedure TCustomSQLQuery.Post;
|
||||||
begin
|
begin
|
||||||
inherited Post;
|
inherited Post;
|
||||||
If (sqoAutoApplyUpdates in QueryOptions) then
|
If (sqoAutoApplyUpdates in Options) then
|
||||||
ApplyUpdates;
|
ApplyUpdates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TCustomSQLQuery.Delete;
|
Procedure TCustomSQLQuery.Delete;
|
||||||
begin
|
begin
|
||||||
inherited Delete;
|
inherited Delete;
|
||||||
If (sqoAutoApplyUpdates in QueryOptions) then
|
If (sqoAutoApplyUpdates in Options) then
|
||||||
ApplyUpdates;
|
ApplyUpdates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2572,12 +2574,12 @@ begin
|
|||||||
FStatement.ParamCheck:=AValue;
|
FStatement.ParamCheck:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSQLQuery.SetQueryOptions(AValue: TSQLQueryOptions);
|
procedure TCustomSQLQuery.SetOptions(AValue: TSQLQueryOptions);
|
||||||
begin
|
begin
|
||||||
if FQueryOptions=AValue then Exit;
|
if FOptions=AValue then Exit;
|
||||||
CheckInactive;
|
CheckInactive;
|
||||||
FQueryOptions:=AValue;
|
FOptions:=AValue;
|
||||||
if sqoDisconnected in FQueryOptions then
|
if sqoKeepOpenOnCommit in FOptions then
|
||||||
PacketRecords:=-1;
|
PacketRecords:=-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -719,17 +719,17 @@ begin
|
|||||||
if assigned(FTransaction) then
|
if assigned(FTransaction) then
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
if not (toUseImplicit in Transaction.Options) then
|
if not (stoUseImplicit in Transaction.Options) then
|
||||||
begin
|
begin
|
||||||
if Ftransaction.Active then
|
if Ftransaction.Active then
|
||||||
Ftransaction.Rollback;
|
Ftransaction.Rollback;
|
||||||
Ftransaction.StartTransaction;
|
Ftransaction.StartTransaction;
|
||||||
end;
|
end;
|
||||||
TryDropIfExist('FPDEV2');
|
TryDropIfExist('FPDEV2');
|
||||||
if not (toUseImplicit in Transaction.Options) then
|
if not (stoUseImplicit in Transaction.Options) then
|
||||||
Ftransaction.Commit;
|
Ftransaction.Commit;
|
||||||
Except
|
Except
|
||||||
if Ftransaction.Active and not (toUseImplicit in Transaction.Options) then
|
if Ftransaction.Active and not (stoUseImplicit in Transaction.Options) then
|
||||||
Ftransaction.Rollback;
|
Ftransaction.Rollback;
|
||||||
end; // try
|
end; // try
|
||||||
end;
|
end;
|
||||||
|
@ -46,7 +46,7 @@ type
|
|||||||
Procedure TestAutoApplyUpdatesPost;
|
Procedure TestAutoApplyUpdatesPost;
|
||||||
Procedure TestAutoApplyUpdatesDelete;
|
Procedure TestAutoApplyUpdatesDelete;
|
||||||
Procedure TestCheckRowsAffected;
|
Procedure TestCheckRowsAffected;
|
||||||
Procedure TestAutoCOmmit;
|
Procedure TestAutoCommit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTestTSQLConnection }
|
{ TTestTSQLConnection }
|
||||||
@ -192,7 +192,7 @@ begin
|
|||||||
Transaction.COmmit;
|
Transaction.COmmit;
|
||||||
Q := SQLDBConnector.Query;
|
Q := SQLDBConnector.Query;
|
||||||
Q.SQL.Text:='select * from testdiscon';
|
Q.SQL.Text:='select * from testdiscon';
|
||||||
Q.QueryOptions:=[sqoDisconnected];
|
Q.Options:=[sqoKeepOpenOnCommit];
|
||||||
AssertEquals('PacketRecords forced to -1',-1,Q.PacketRecords);
|
AssertEquals('PacketRecords forced to -1',-1,Q.PacketRecords);
|
||||||
Q.Open;
|
Q.Open;
|
||||||
AssertEquals('Got all records',20,Q.RecordCount);
|
AssertEquals('Got all records',20,Q.RecordCount);
|
||||||
@ -231,15 +231,15 @@ begin
|
|||||||
with SQLDBConnector do
|
with SQLDBConnector do
|
||||||
begin
|
begin
|
||||||
FMyQ := SQLDBConnector.Query;
|
FMyQ := SQLDBConnector.Query;
|
||||||
FMyQ.QueryOptions:=[sqoDisconnected];
|
FMyQ.Options:=[sqoKeepOpenOnCommit];
|
||||||
AssertException('Cannot set packetrecords when sqoDisconnected is active',EDatabaseError,@TrySetPacketRecords);
|
AssertException('Cannot set PacketRecords when sqoKeepOpenOnCommit is active',EDatabaseError,@TrySetPacketRecords);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TTestTSQLQuery.SetQueryOPtions;
|
Procedure TTestTSQLQuery.SetQueryOptions;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FMyQ.QueryOptions:=[sqoDisconnected];
|
FMyQ.Options:=[sqoKeepOpenOnCommit];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TTestTSQLQuery.TestCheckSettingsOnlyWhenInactive;
|
Procedure TTestTSQLQuery.TestCheckSettingsOnlyWhenInactive;
|
||||||
@ -277,7 +277,7 @@ begin
|
|||||||
Q := SQLDBConnector.Query;
|
Q := SQLDBConnector.Query;
|
||||||
FMyQ:=Q; // so th event handler can reach it.
|
FMyQ:=Q; // so th event handler can reach it.
|
||||||
Q.SQL.Text:='select * from testdiscon';
|
Q.SQL.Text:='select * from testdiscon';
|
||||||
Q.QueryOptions:=[ sqoAutoApplyUpdates];
|
Q.Options:=[sqoAutoApplyUpdates];
|
||||||
// We must test that in AfterPost, the modification is still there, for backwards compatibilty
|
// We must test that in AfterPost, the modification is still there, for backwards compatibilty
|
||||||
Q.AfterPost:=@DoAfterPost;
|
Q.AfterPost:=@DoAfterPost;
|
||||||
Q.Open;
|
Q.Open;
|
||||||
@ -313,7 +313,7 @@ begin
|
|||||||
Q := SQLDBConnector.Query;
|
Q := SQLDBConnector.Query;
|
||||||
FMyQ:=Q; // so th event handler can reach it.
|
FMyQ:=Q; // so th event handler can reach it.
|
||||||
Q.SQL.Text:='select * from testdiscon';
|
Q.SQL.Text:='select * from testdiscon';
|
||||||
Q.QueryOptions:=[ sqoAutoApplyUpdates];
|
Q.Options:=[sqoAutoApplyUpdates];
|
||||||
// We must test that in AfterPost, the modification is still there, for backwards compatibilty
|
// We must test that in AfterPost, the modification is still there, for backwards compatibilty
|
||||||
Q.AfterPost:=@DoAfterPost;
|
Q.AfterPost:=@DoAfterPost;
|
||||||
Q.Open;
|
Q.Open;
|
||||||
@ -348,7 +348,7 @@ begin
|
|||||||
for I:=1 to 2 do
|
for I:=1 to 2 do
|
||||||
ExecuteDirect(Format('INSERT INTO testdiscon values (%d,''%.6d'')',[i,i]));
|
ExecuteDirect(Format('INSERT INTO testdiscon values (%d,''%.6d'')',[i,i]));
|
||||||
Transaction.COmmit;
|
Transaction.COmmit;
|
||||||
SQLDBConnector.Connection.Options:=[coCheckRowsAffected];
|
SQLDBConnector.Connection.Options:=[scoApplyUpdatesChecksRowsAffected];
|
||||||
Q := SQLDBConnector.Query;
|
Q := SQLDBConnector.Query;
|
||||||
Q.SQL.Text:='select * from testdiscon';
|
Q.SQL.Text:='select * from testdiscon';
|
||||||
Q.DeleteSQL.Text:='delete from testdiscon';
|
Q.DeleteSQL.Text:='delete from testdiscon';
|
||||||
@ -361,7 +361,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TTestTSQLQuery.TestAutoCOmmit;
|
Procedure TTestTSQLQuery.TestAutoCommit;
|
||||||
var
|
var
|
||||||
Q: TSQLQuery;
|
Q: TSQLQuery;
|
||||||
T : TSQLTransaction;
|
T : TSQLTransaction;
|
||||||
@ -375,7 +375,7 @@ begin
|
|||||||
Transaction.Commit;
|
Transaction.Commit;
|
||||||
end;
|
end;
|
||||||
Q:=SQLDBConnector.Query;
|
Q:=SQLDBConnector.Query;
|
||||||
Q.QueryOptions:=[sqoAutoCommit];
|
Q.Options:=[sqoAutoCommit];
|
||||||
for I:=1 to 2 do
|
for I:=1 to 2 do
|
||||||
begin
|
begin
|
||||||
Q.SQL.Text:=Format('INSERT INTO testdiscon values (%d,''%.6d'');',[i,i]);
|
Q.SQL.Text:=Format('INSERT INTO testdiscon values (%d,''%.6d'');',[i,i]);
|
||||||
@ -411,7 +411,7 @@ Var
|
|||||||
begin
|
begin
|
||||||
T:=TSQLTransaction.Create(Nil);
|
T:=TSQLTransaction.Create(Nil);
|
||||||
try
|
try
|
||||||
T.Options:=[toUseImplicit];
|
T.Options:=[stoUseImplicit];
|
||||||
T.DataBase:=SQLDBConnector.Connection;
|
T.DataBase:=SQLDBConnector.Connection;
|
||||||
finally
|
finally
|
||||||
T.Free;
|
T.Free;
|
||||||
@ -426,7 +426,7 @@ Var
|
|||||||
begin
|
begin
|
||||||
T:=TSQLTransaction.Create(Nil);
|
T:=TSQLTransaction.Create(Nil);
|
||||||
try
|
try
|
||||||
T.Options:=[toUseImplicit];
|
T.Options:=[stoUseImplicit];
|
||||||
SQLDBConnector.Connection.Transaction:=T;
|
SQLDBConnector.Connection.Transaction:=T;
|
||||||
finally
|
finally
|
||||||
T.Free;
|
T.Free;
|
||||||
@ -436,7 +436,7 @@ end;
|
|||||||
procedure TTestTSQLConnection.SetImplicit;
|
procedure TTestTSQLConnection.SetImplicit;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SQLDBConnector.Transaction.Options:=[toUseImplicit];
|
SQLDBConnector.Transaction.Options:=[stoUseImplicit];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTestTSQLConnection.TestImplicitTransactionNotAssignable;
|
procedure TTestTSQLConnection.TestImplicitTransactionNotAssignable;
|
||||||
@ -505,7 +505,7 @@ end;
|
|||||||
procedure TTestTSQLConnection.TestUseExplicitTransaction;
|
procedure TTestTSQLConnection.TestUseExplicitTransaction;
|
||||||
begin
|
begin
|
||||||
SQLDBConnector.Transaction.Active:=False;
|
SQLDBConnector.Transaction.Active:=False;
|
||||||
SQLDBConnector.Transaction.Options:=[toExplicitStart];
|
SQLDBConnector.Transaction.Options:=[stoExplicitStart];
|
||||||
SQLDBConnector.Query.SQL.Text:='select * from FPDEV';
|
SQLDBConnector.Query.SQL.Text:='select * from FPDEV';
|
||||||
AssertException('toExplicitStart raises exception on implicit start',EDatabaseError,@TryOpen)
|
AssertException('toExplicitStart raises exception on implicit start',EDatabaseError,@TryOpen)
|
||||||
end;
|
end;
|
||||||
@ -513,7 +513,7 @@ end;
|
|||||||
procedure TTestTSQLConnection.TestExplicitConnect;
|
procedure TTestTSQLConnection.TestExplicitConnect;
|
||||||
begin
|
begin
|
||||||
SQLDBConnector.Transaction.Active:=False;
|
SQLDBConnector.Transaction.Active:=False;
|
||||||
SQLDBConnector.Connection.Options:=[coExplicitConnect];
|
SQLDBConnector.Connection.Options:=[scoExplicitConnect];
|
||||||
SQLDBConnector.Connection.Connected:=False;
|
SQLDBConnector.Connection.Connected:=False;
|
||||||
SQLDBConnector.Query.SQL.Text:='select * from FPDEV';
|
SQLDBConnector.Query.SQL.Text:='select * from FPDEV';
|
||||||
AssertException('toExplicitStart raises exception on implicit start',EDatabaseError,@TryOpen)
|
AssertException('toExplicitStart raises exception on implicit start',EDatabaseError,@TryOpen)
|
||||||
@ -650,7 +650,7 @@ begin
|
|||||||
DBConnector.StopTest(TestName);
|
DBConnector.StopTest(TestName);
|
||||||
if assigned(DBConnector) then
|
if assigned(DBConnector) then
|
||||||
with SQLDBConnector do
|
with SQLDBConnector do
|
||||||
if Assigned(Transaction) and not (toUseImplicit in Transaction.Options) then
|
if Assigned(Transaction) and not (stoUseImplicit in Transaction.Options) then
|
||||||
Transaction.Rollback;
|
Transaction.Rollback;
|
||||||
FreeDBConnector;
|
FreeDBConnector;
|
||||||
inherited TearDown;
|
inherited TearDown;
|
||||||
|
Loading…
Reference in New Issue
Block a user