ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/nongui/IBTable.pas
(Generate patch)

Comparing ibx/trunk/runtime/nongui/IBTable.pas (file contents):
Revision 209 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 410 by tony, Thu Jun 22 13:52:39 2023 UTC

# Line 39 | Line 39 | unit IBTable;
39  
40   interface
41  
42 < uses SysUtils, Classes, DB, IB,  IBCustomDataSet,
43 <     IBSQL, IBUtils;
42 > uses SysUtils, Classes, DB, IB,  IBCustomDataSet, IBDatabase, IBSQL, IBUtils,
43 >  IBBufferedCursors;
44      
45   type
46  
# Line 127 | Line 127 | type
127      procedure SetFiltered(Value: Boolean); override;
128      procedure SetFilterText(const Value: string); override;
129      procedure SetFilterOptions(Value: TFilterOptions); override;
130 <    procedure InternalRefreshRow; override;
130 >    procedure InternalRefreshRow(Buff: TRecordBuffer); override;
131      function GetMasterDetailDelay: integer; override;
132      procedure SetMasterDetailDelay(AValue: integer); override;
133  
# Line 154 | Line 154 | type
154      property AutoCommit;
155      property Active;
156      property BufferChunks;
157 +    property BufferChunksInFirstBlock;
158      property CachedUpdates;
159      property DataSetCloseAction;
160   //    property Constraints stored ConstraintsStored;
# Line 161 | Line 162 | type
162      property EnableStatistics;
163      property Filter;
164      property Filtered;
165 +    property SQLFiltered;
166 +    property SQLFilterParams;
167      property GeneratorField;
168      property IndexDefs: TIndexDefs read FIndexDefs write SetIndexDefs stored IndexDefsStored;
169      property IndexFieldNames: string read GetIndexFieldNames write SetIndexFieldNames;
# Line 186 | Line 189 | type
189  
190   implementation
191  
192 < uses FBMessages, fpTimer;
192 > uses IBMessages, IBInternals;
193  
194   type
195  
# Line 195 | Line 198 | type
198    TIBMasterDataLink = class(TMasterDataLink)
199    private
200      FDelayTimerValue: integer;
201 <    FTimer: TFPTimer;
201 >    FTimer: IIBTimerInf;
202      procedure HandleRefreshTimer(Sender: TObject);
203 +    procedure SetDelayTimerValue(AValue: integer);
204    protected
205      procedure DoMasterChange; override;
206    public
207      constructor Create(ADataSet: TDataSet); override;
204    destructor Destroy; override;
208      property DelayTimerValue: integer {in Milliseconds}
209 <            read FDelayTimerValue write FDelayTimerValue;
209 >            read FDelayTimerValue write SetDelayTimerValue;
210    end;
211  
212   { TIBMasterDataLink }
213  
214   procedure TIBMasterDataLink.HandleRefreshTimer(Sender: TObject);
215   begin
216 <  FTimer.Interval := 0;
217 <  inherited DoMasterChange;
216 >  FTimer.Enabled := false;
217 >  if GetDetailDataSet.Active then
218 >    inherited DoMasterChange;
219 > end;
220 >
221 > procedure TIBMasterDataLink.SetDelayTimerValue(AValue: integer);
222 > begin
223 >  if FDelayTimerValue = AValue then Exit;
224 >  if assigned(FTimer) then
225 >    FTimer.Enabled := false;
226 >  FDelayTimerValue := AValue;
227   end;
228  
229   procedure TIBMasterDataLink.DoMasterChange;
230   begin
231 <  if FDelayTimerValue = 0 then
232 <    inherited DoMasterChange
221 <  else
231 >  if assigned(FTimer) and (FDelayTimerValue > 0) then
232 >  with FTimer do
233    begin
234 +    FTimer.Enabled := false;
235      FTimer.Interval := FDelayTimerValue;
236 <    FTimer.StartTimer;
237 <  end;
236 >    FTimer.Enabled := true;
237 >  end
238 >  else
239 >    inherited DoMasterChange
240   end;
241  
242   constructor TIBMasterDataLink.Create(ADataSet: TDataSet);
243   begin
244    inherited Create(ADataSet);
245 <  FTimer := TFPTimer.Create(nil);
246 <  FTimer.Enabled := true;
247 <  FTimer.Interval := 0;
248 <  FTimer.OnTimer := HandleRefreshTimer;
245 >  if assigned(IBGUIInterface) then
246 >  begin
247 >    FTimer := IBGUIInterface.CreateTimer;
248 >    if FTimer <> nil then
249 >    begin
250 >      FTimer.Enabled := false;
251 >      FTimer.Interval := 0;
252 >      FTimer.OnTimer := HandleRefreshTimer;
253 >    end;
254 >  end;
255    FDelayTimerValue := 0;
256   end;
257  
238 destructor TIBMasterDataLink.Destroy;
239 begin
240  if assigned(FTimer) then FTimer.Free;
241  inherited Destroy;
242 end;
243
258   { TIBTable }
259  
260   constructor TIBTable.Create(AOwner: TComponent);
# Line 344 | Line 358 | begin
358      IBError(ibxeNotSupported, [nil]);
359   end;
360  
361 < procedure TIBTable.InternalRefreshRow;
361 > procedure TIBTable.InternalRefreshRow(Buff: TRecordBuffer);
362   begin
363    if CurrentDBKey.DBKey[0] <> 0 then
364      QRefresh.SQL.Assign(WhereDBKeyRefreshSQL)
# Line 352 | Line 366 | begin
366      QRefresh.SQL.Assign(WherePrimaryRefreshSQL)
367    else
368      QRefresh.SQL.Assign(WhereAllRefreshSQL);
369 <  inherited InternalRefreshRow;
369 >  inherited InternalRefreshRow(Buff);
370   end;
371  
372   function TIBTable.GetMasterDetailDelay: integer;
# Line 541 | Line 555 | var
555          ExtractIdentifier(Database.SQLDialect,
556            QuoteIdentifier(DataBase.SQLDialect, Name)) +
557          ''' ' +
558 <        'AND RDB$CONSTRAINT_TYPE = ''PRIMARY KEY''';
558 >        'AND Trim(RDB$CONSTRAINT_TYPE) = ''PRIMARY KEY''';
559        Query.Prepare;
560        Query.ExecQuery;
561        if not Query.EOF then
# Line 735 | Line 749 | begin
749      Query.Database := DataBase;
750      Query.Transaction := Database.InternalTransaction;
751      Query.SQL.Text :=
752 <    'Select USER from RDB$RELATIONS where RDB$RELATION_NAME = ' + {do not localize}
752 >    'Select USER from RDB$RELATIONS where Trim(RDB$RELATION_NAME) = ' + {do not localize}
753      '''' +
754      ExtractIdentifier(Database.SQLDialect,
755        QuoteIdentifier(DataBase.SQLDialect, FTableName)) + '''';
# Line 850 | Line 864 | var
864              FieldList := FieldList +
865                QuoteIdentifier(DataBase.SQLDialect, Name) +
866                ' BLOB SUB_TYPE 0'; {do not localize}
867 +          ftFmtBCD:
868 +            if Database.Attachment.HasDecFloatSupport then
869 +              FieldList := FieldList +
870 +                QuoteIdentifier(DataBase.SQLDialect, Name) +
871 +                ' Decfloat(34)' {do not localize}
872 +            else
873 +              IBError(ibxeFieldUnsupportedType,[nil]);
874            ftUnknown, ftADT, ftArray, ftReference, ftDataSet,
875            ftCursor, ftWideString, ftAutoInc:
876              IBError(ibxeFieldUnsupportedType,[nil]);
# Line 946 | Line 967 | begin
967      if Active then
968      begin
969        ClearBuffers;
970 +      ReQuery;
971        DataEvent(deDataSetChange, 0);
972      end;
973    finally
# Line 982 | Line 1004 | begin
1004      Query.Database := DataBase;
1005      Query.Transaction := Database.InternalTransaction;
1006      Query.SQL.Text := 'Select RDB$SYSTEM_FLAG, RDB$DBKEY_LENGTH ' + {do not localize}
1007 <                    'from RDB$RELATIONS where RDB$RELATION_NAME = ' + {do not localize}
1007 >                    'from RDB$RELATIONS where Trim(RDB$RELATION_NAME)  = ' + {do not localize}
1008                      '''' +
1009                      ExtractIdentifier(Database.SQLDialect,
1010                        QuoteIdentifier(DataBase.SQLDialect, FTableName)) + '''';
# Line 1026 | Line 1048 | end;
1048   procedure TIBTable.MasterDisabled(Sender: TObject);
1049   begin
1050    DataEvent(dePropertyChange, 0);
1029  ReQuery;
1051   end;
1052  
1053   function TIBTable.GetDataSource: TDataSource;
# Line 1318 | Line 1339 | begin
1339    SQL := TStringList.Create;
1340    SQL.Text := 'select ' + {do not localize}
1341      QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize}
1342 <    + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize}
1342 >    + 'RDB$DB_KEY as ' + sDBkeyAlias + ' from ' {do not localize}
1343      + QuoteIdentifier(DataBase.SQLDialect, FTableName);
1344    if Filtered and (Filter <> '') then
1345    begin
# Line 1352 | Line 1373 | begin
1373    SelectSQL.Assign(SQL);
1374    RefreshSQL.Text := 'select ' + {do not localize}
1375      QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize}
1376 <    + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize}
1376 >    + 'RDB$DB_KEY as ' + sDBkeyAlias + ' from ' {do not localize}
1377      + QuoteIdentifier(DataBase.SQLDialect, FTableName) +
1378 <    ' where RDB$DB_KEY = :IBX_INTERNAL_DBKEY'; {do not localize}
1378 >    ' where RDB$DB_KEY = :' + sDBkeyAlias; {do not localize}
1379    WhereDBKeyRefreshSQL.Assign(RefreshSQL);
1380    InternalPrepare;
1381    SQL.Free;
# Line 1459 | Line 1480 | begin
1480    begin
1481      DeleteSQL.Text := 'delete from ' + {do not localize}
1482        QuoteIdentifier(DataBase.SQLDialect, FTableName) +
1483 <      ' where RDB$DB_KEY = ' + ':IBX_INTERNAL_DBKEY'; {do not localize}
1483 >      ' where RDB$DB_KEY = ' + ':' + sDBkeyAlias; {do not localize}
1484      GenerateFieldLists;
1485      InsertSQL.Text := 'insert into ' + {do not localize}
1486        QuoteIdentifier(DataBase.SQLDialect, FTableName) +
# Line 1468 | Line 1489 | begin
1489      ModifySQL.Text := 'update ' +
1490        QuoteIdentifier(DataBase.SQLDialect, FTableName) +
1491        ' set ' + UpdateFieldList + {do not localize}
1492 <      ' where RDB$DB_KEY = :IBX_INTERNAL_DBKEY' + UpdateReturningFieldList; {do not localize}
1492 >      ' where RDB$DB_KEY = :' + sDBkeyAlias + UpdateReturningFieldList; {do not localize}
1493      WhereAllRefreshSQL.Text := 'select ' +  {do not localize}
1494        QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, '
1495 <      + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize}
1495 >      + 'RDB$DB_KEY as ' + sDBkeyAlias + ' from ' {do not localize}
1496        + QuoteIdentifier(DataBase.SQLDialect, FTableName) +
1497        ' where ' + WhereAllFieldList ; {do not localize}
1498      if FPrimaryIndexFields <> '' then
# Line 1479 | Line 1500 | begin
1500        GenerateWherePrimaryFieldList;
1501        WherePrimaryRefreshSQL.Text := 'select ' + {do not localize}
1502          QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize}
1503 <        + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize}
1503 >        + 'RDB$DB_KEY as ' + sDBkeyAlias + ' from ' {do not localize}
1504          + QuoteIdentifier(DataBase.SQLDialect, FTableName) +
1505          ' where ' + WherePrimaryFieldList; {do not localize}
1506      end;
# Line 1526 | Line 1547 | begin
1547      result := False;
1548      First;
1549      while ((not result) and (not EOF)) do begin
1550 <      if (DBKeyCompare (DBKey, PRecordData(GetActiveBuf)^.rdDBKey)) then
1550 >      if (DBKeyCompare (DBKey, GetCurrentDBKey)) then
1551          result := True
1552        else
1553          Next;
# Line 1541 | Line 1562 | begin
1562   end;
1563  
1564   function TIBTable.GetCurrentDBKey: TIBDBKey;
1544 var
1545  Buf: pChar;
1565   begin
1566    CheckActive;
1567 <  buf := GetActiveBuf;
1549 <  if Buf <> nil then
1550 <    Result := PRecordData(Buf)^.rdDBKey
1551 <  else
1552 <    Result.DBKey[0] := 0;
1567 >  Result := Cursor.GetRecDBkey(GetActiveBuf);
1568   end;
1569  
1570   procedure TIBTable.Reopen;

Comparing ibx/trunk/runtime/nongui/IBTable.pas (property svn:eol-style):
Revision 209 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 410 by tony, Thu Jun 22 13:52:39 2023 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines