|
@@ -402,7 +402,7 @@ type
|
|
|
|
|
|
{ TCustomSQLQuery }
|
|
{ TCustomSQLQuery }
|
|
|
|
|
|
- TSQLQueryOption = (sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit);
|
|
|
|
|
|
+ TSQLQueryOption = (sqoKeepOpenOnCommit, sqoAutoApplyUpdates, sqoAutoCommit, sqoCancelUpdatesOnRefresh);
|
|
TSQLQueryOptions = Set of TSQLQueryOption;
|
|
TSQLQueryOptions = Set of TSQLQueryOption;
|
|
|
|
|
|
TCustomSQLQuery = class (TCustomBufDataset)
|
|
TCustomSQLQuery = class (TCustomBufDataset)
|
|
@@ -483,6 +483,7 @@ type
|
|
procedure InternalClose; override;
|
|
procedure InternalClose; override;
|
|
procedure InternalInitFieldDefs; override;
|
|
procedure InternalInitFieldDefs; override;
|
|
procedure InternalOpen; override;
|
|
procedure InternalOpen; override;
|
|
|
|
+ Procedure InternalRefresh; override;
|
|
function GetCanModify: Boolean; override;
|
|
function GetCanModify: Boolean; override;
|
|
Function IsPrepared : Boolean; virtual;
|
|
Function IsPrepared : Boolean; virtual;
|
|
Procedure SetActive (Value : Boolean); override;
|
|
Procedure SetActive (Value : Boolean); override;
|
|
@@ -2234,7 +2235,7 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCustomSQLQuery.ParamByName(Const AParamName: String): TParam;
|
|
|
|
|
|
+function TCustomSQLQuery.ParamByName(const AParamName: String): TParam;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=Params.ParamByName(AParamName);
|
|
Result:=Params.ParamByName(AParamName);
|
|
@@ -2246,7 +2247,7 @@ begin
|
|
CheckInactive;
|
|
CheckInactive;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.SetTransaction(Value: TDBTransaction);
|
|
|
|
|
|
+procedure TCustomSQLQuery.SetTransaction(Value: TDBTransaction);
|
|
|
|
|
|
begin
|
|
begin
|
|
UnPrepare;
|
|
UnPrepare;
|
|
@@ -2276,7 +2277,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.IsPrepared: Boolean;
|
|
|
|
|
|
+function TCustomSQLQuery.IsPrepared: Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
if Assigned(Fstatement) then
|
|
if Assigned(Fstatement) then
|
|
@@ -2285,7 +2286,7 @@ begin
|
|
Result := False;
|
|
Result := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.AddFilter(SQLstr: string): string;
|
|
|
|
|
|
+function TCustomSQLQuery.AddFilter(SQLstr: string): string;
|
|
|
|
|
|
begin
|
|
begin
|
|
if (FWhereStartPos > 0) and (FWhereStopPos > 0) then
|
|
if (FWhereStartPos > 0) and (FWhereStopPos > 0) then
|
|
@@ -2303,7 +2304,7 @@ begin
|
|
Result := SQLstr;
|
|
Result := SQLstr;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.NeedRefreshRecord(UpdateKind: TUpdateKind): Boolean;
|
|
|
|
|
|
+function TCustomSQLQuery.NeedRefreshRecord(UpdateKind: TUpdateKind): Boolean;
|
|
|
|
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -2323,7 +2324,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.RefreshRecord(UpdateKind: TUpdateKind) : Boolean;
|
|
|
|
|
|
+function TCustomSQLQuery.RefreshRecord(UpdateKind: TUpdateKind): Boolean;
|
|
|
|
|
|
Var
|
|
Var
|
|
Q : TCustomSQLQuery;
|
|
Q : TCustomSQLQuery;
|
|
@@ -2386,7 +2387,7 @@ begin
|
|
First;
|
|
First;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.SetActive(Value: Boolean);
|
|
|
|
|
|
+procedure TCustomSQLQuery.SetActive(Value: Boolean);
|
|
|
|
|
|
begin
|
|
begin
|
|
inherited SetActive(Value);
|
|
inherited SetActive(Value);
|
|
@@ -2461,7 +2462,7 @@ begin
|
|
Result := FServerIndexDefs;
|
|
Result := FServerIndexDefs;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TCustomSQLQuery.GetSQL: TStringlist;
|
|
|
|
|
|
+function TCustomSQLQuery.GetSQL: TStringList;
|
|
begin
|
|
begin
|
|
Result:=TStringList(Fstatement.SQL);
|
|
Result:=TStringList(Fstatement.SQL);
|
|
end;
|
|
end;
|
|
@@ -2476,7 +2477,7 @@ begin
|
|
Result:=Transaction as TSQLTransaction;
|
|
Result:=Transaction as TSQLTransaction;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.Cursor: TSQLCursor;
|
|
|
|
|
|
+function TCustomSQLQuery.Cursor: TSQLCursor;
|
|
begin
|
|
begin
|
|
Result:=FStatement.Cursor;
|
|
Result:=FStatement.Cursor;
|
|
end;
|
|
end;
|
|
@@ -2623,6 +2624,13 @@ begin
|
|
inherited InternalOpen;
|
|
inherited InternalOpen;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TCustomSQLQuery.InternalRefresh;
|
|
|
|
+begin
|
|
|
|
+ if (sqoCancelUpdatesOnRefresh in Options) then
|
|
|
|
+ CancelUpdates;
|
|
|
|
+ inherited InternalRefresh;
|
|
|
|
+end;
|
|
|
|
+
|
|
// public part
|
|
// public part
|
|
|
|
|
|
procedure TCustomSQLQuery.ExecSQL;
|
|
procedure TCustomSQLQuery.ExecSQL;
|
|
@@ -2644,7 +2652,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.ApplyUpdates(MaxErrors: Integer);
|
|
|
|
|
|
+procedure TCustomSQLQuery.ApplyUpdates(MaxErrors: Integer);
|
|
begin
|
|
begin
|
|
inherited ApplyUpdates(MaxErrors);
|
|
inherited ApplyUpdates(MaxErrors);
|
|
If sqoAutoCommit in Options then
|
|
If sqoAutoCommit in Options then
|
|
@@ -2655,14 +2663,14 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.Post;
|
|
|
|
|
|
+procedure TCustomSQLQuery.Post;
|
|
begin
|
|
begin
|
|
inherited Post;
|
|
inherited Post;
|
|
If (sqoAutoApplyUpdates in Options) 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 Options) then
|
|
If (sqoAutoApplyUpdates in Options) then
|
|
@@ -2685,7 +2693,7 @@ begin
|
|
FServerFiltered := False;
|
|
FServerFiltered := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TCustomSQLQuery.SetSQL(const AValue: TStringlist);
|
|
|
|
|
|
+procedure TCustomSQLQuery.SetSQL(const AValue: TStringList);
|
|
begin
|
|
begin
|
|
FStatement.SQL.Assign(AValue);
|
|
FStatement.SQL.Assign(AValue);
|
|
end;
|
|
end;
|
|
@@ -2709,7 +2717,7 @@ begin
|
|
SQLConnection.UpdateIndexDefs(ServerIndexDefs,FTableName);
|
|
SQLConnection.UpdateIndexDefs(ServerIndexDefs,FTableName);
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.NeedLastInsertID : TField;
|
|
|
|
|
|
+function TCustomSQLQuery.NeedLastInsertID: TField;
|
|
|
|
|
|
Var
|
|
Var
|
|
I : Integer;
|
|
I : Integer;
|
|
@@ -2729,7 +2737,7 @@ begin
|
|
end
|
|
end
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.RefreshLastInsertID(Field : TField) : Boolean;
|
|
|
|
|
|
+function TCustomSQLQuery.RefreshLastInsertID(Field: TField): Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=SQLConnection.RefreshLastInsertID(Self, Field);
|
|
Result:=SQLConnection.RefreshLastInsertID(Self, Field);
|
|
@@ -2815,12 +2823,12 @@ begin
|
|
UnPrepareStatement(Cursor);
|
|
UnPrepareStatement(Cursor);
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.LogEvent(EventType: TDBEventType): Boolean;
|
|
|
|
|
|
+function TCustomSQLQuery.LogEvent(EventType: TDBEventType): Boolean;
|
|
begin
|
|
begin
|
|
Result:=Assigned(Database) and SQLConnection.LogEvent(EventType);
|
|
Result:=Assigned(Database) and SQLConnection.LogEvent(EventType);
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.Log(EventType: TDBEventType; Const Msg: String);
|
|
|
|
|
|
+procedure TCustomSQLQuery.Log(EventType: TDBEventType; const Msg: String);
|
|
|
|
|
|
Var
|
|
Var
|
|
M : String;
|
|
M : String;
|
|
@@ -2899,7 +2907,7 @@ begin
|
|
FStatement.Params.Assign(AValue);
|
|
FStatement.Params.Assign(AValue);
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure TCustomSQLQuery.SetDataSource(AValue: TDataSource);
|
|
|
|
|
|
+procedure TCustomSQLQuery.SetDataSource(AValue: TDataSource);
|
|
|
|
|
|
Var
|
|
Var
|
|
DS : TDataSource;
|
|
DS : TDataSource;
|
|
@@ -2916,7 +2924,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-Function TCustomSQLQuery.GetDataSource: TDataSource;
|
|
|
|
|
|
+function TCustomSQLQuery.GetDataSource: TDataSource;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Assigned(FStatement) then
|
|
If Assigned(FStatement) then
|