--- ibx/trunk/runtime/IBTable.pas 2000/07/31 16:43:00 1 +++ ibx/trunk/runtime/IBTable.pas 2011/02/18 16:26:16 5 @@ -28,11 +28,13 @@ unit IBTable; -interface +{$Mode Delphi} -uses Windows, SysUtils, Graphics, Classes, Controls, Db, StdVCL, - IB, IBDatabase, IBCustomDataSet, IBHeader, IBSQL, IBUtils; +interface +uses SysUtils, Classes, DB, IB, IBCustomDataSet, + IBHeader, IBSQL, IBUtils; + type { TIBTable } @@ -103,21 +105,14 @@ type procedure Reopen; protected - { IProviderSupport } - function PSGetDefaultOrder: TIndexDef; override; - function PSGetKeyFields: string; override; - function PSGetTableName: string; override; - function PSGetIndexDefs(IndexTypes: TIndexOptions): TIndexDefs; override; - procedure PSSetCommandText(const CommandText: string); override; - procedure PSSetParams(AParams: TParams); override; procedure DoOnNewRecord; override; procedure GetIndexParams(const IndexName: string; FieldsIndex: Boolean; var IndexedName: string); function GetCanModify: Boolean; override; procedure UpdateIndexDefs; override; - procedure DataEvent(Event: TDataEvent; Info: Longint); override; - procedure DefChanged(Sender: TObject); override; + procedure DataEvent(Event: TDataEvent; Info: Ptrint); override; + procedure DefChanged(Sender: TObject); virtual; function GetDataSource: TDataSource; override; procedure InitFieldDefs; override; procedure InternalClose; override; @@ -137,7 +132,7 @@ type procedure DeleteIndex(const Name: string); procedure DeleteTable; procedure EmptyTable; - procedure GetDetailLinkFields(MasterFields, DetailFields: TList); override; + procedure GetDetailLinkFields(MasterFields, DetailFields: TList); virtual; procedure GetIndexNames(List: TStrings); procedure GotoCurrent(Table: TIBTable); property CurrentDBKey: TIBDBKey read GetCurrentDBKey; @@ -285,7 +280,7 @@ begin QRefresh.SQL.Assign(WherePrimaryRefreshSQL) else QRefresh.SQL.Assign(WhereAllRefreshSQL); - inherited; + inherited InternalRefreshRow; end; procedure TIBTable.DefChanged(Sender: TObject); @@ -316,7 +311,8 @@ begin 'from RDB$RELATION_FIELDS R, RDB$FIELDS F ' + {do not localize} 'where R.RDB$RELATION_NAME = ' + {do not localize} '''' + - FormatIdentifierValue(Database.SQLDialect, FTableName) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''' ' + 'and R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME '+ {do not localize} 'order by R.RDB$FIELD_POSITION'; {do not localize} @@ -329,41 +325,50 @@ begin begin with FieldDefs.AddFieldDef do begin - FieldNo := Query.Current.ByName('RDB$FIELD_POSITION').AsInteger; {do not localize} + (* FieldNo := Query.Current.ByName('RDB$FIELD_POSITION').AsInteger; {do not localize}*) Name := TrimRight(Query.Current.ByName('RDB$FIELD_NAME').AsString); {do not localize} case Query.Current.ByName('RDB$FIELD_TYPE').AsInteger of {do not localize} - blr_varying, blr_text: begin + blr_varying, blr_text: + begin DataType := ftString; Size := Query.Current.ByName('RDB$FIELD_LENGTH').AsInteger; {do not localize} end; blr_float, blr_double, blr_d_float: DataType := ftFloat; - blr_short: begin + blr_short: + begin sqlscale := Query.Current.ByName('RDB$FIELD_SCALE').AsInteger; {do not localize} if (sqlscale = 0) then DataType := ftSmallInt - else begin + else + begin DataType := ftBCD; Precision := 4; end; end; - blr_long: begin + blr_long: + begin sqlscale := Query.Current.ByName('RDB$FIELD_SCALE').AsInteger; {do not localize} if (sqlscale = 0) then DataType := ftInteger - else if (sqlscale >= (-4)) then begin + else if (sqlscale >= (-4)) then + begin DataType := ftBCD; Precision := 9; - end else + end + else DataType := ftFloat; end; - blr_int64: begin + blr_int64: + begin sqlscale := Query.Current.ByName('RDB$FIELD_SCALE').AsInteger; {do not localize} if (sqlscale = 0) then DataType := ftLargeInt - else if (sqlscale >= (-4)) then begin + else if (sqlscale >= (-4)) then + begin DataType := ftBCD; Precision := 18; - end else + end + else DataType := ftFloat; end; blr_timestamp: DataType := ftDateTime; @@ -374,7 +379,8 @@ begin DataType := ftMemo else DataType := ftBlob; - blr_quad: begin + blr_quad: + begin DataType := ftUnknown; Size := sizeof (TISC_QUAD); end; @@ -390,7 +396,8 @@ begin InternalCalcField := False; if ((not InternalCalcField) and Query.Current.ByName('RDB$DEFAULT_VALUE').IsNull and {do not localize} - (Query.Current.ByName('RDB$NULL_FLAG').AsInteger = 1) )then begin {do not localize} + (Query.Current.ByName('RDB$NULL_FLAG').AsInteger = 1) )then {do not localize} + begin Attributes := [faRequired]; Required := True; end; @@ -425,36 +432,36 @@ begin if (ixPrimary in Options) then begin Query.SQL.Text := 'Alter Table ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(Database.SQLDialect, FTableName) + ' Add CONSTRAINT ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name) + QuoteIdentifier(Database.SQLDialect, Name) + ' Primary Key (' + {do not localize} FormatFieldsList(Fields) + ')'; end else if ([ixUnique, ixDescending] * Options = [ixUnique, ixDescending]) then Query.SQL.Text := 'Create unique Descending Index ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(Database.SQLDialect, Name) + ' on ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(Database.SQLDialect, FTableName) + ' (' + FieldList + ')' else if (ixUnique in Options) then Query.SQL.Text := 'Create unique Index ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(Database.SQLDialect, Name) + ' on ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(Database.SQLDialect, FTableName) + ' (' + FieldList + ')' else if (ixDescending in Options) then Query.SQL.Text := 'Create Descending Index ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(Database.SQLDialect, Name) + ' on ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(Database.SQLDialect, FTableName) + ' (' + FieldList + ')' else Query.SQL.Text := 'Create Index ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(Database.SQLDialect, Name) + ' on ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(Database.SQLDialect, FTableName) + ' (' + FieldList + ')'; Query.Prepare; Query.ExecQuery; @@ -475,7 +482,7 @@ var Query.Database := DataBase; Query.Transaction := Transaction; Query.SQL.Text := 'Drop index ' + {do not localize} - FormatIdentifier(Database.SQLDialect, Name); + QuoteIdentifier(Database.SQLDialect, Name); Query.Prepare; Query.ExecQuery; IndexDefs.Updated := False; @@ -494,11 +501,13 @@ var Query.SQL.Text := 'Select ''foo'' from RDB$RELATION_CONSTRAINTS ' + 'where RDB$RELATION_NAME = ' + '''' + - FormatIdentifierValue(Database.SQLDialect, FTableName) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''' ' + ' AND RDB$CONSTRAINT_NAME = ' + '''' + - FormatIdentifierValue(Database.SQLDialect, Name) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, Name)) + ''' ' + 'AND RDB$CONSTRAINT_TYPE = ''PRIMARY KEY'''; Query.Prepare; @@ -507,9 +516,9 @@ var begin Query.Close; Query.SQL.Text := 'Alter Table ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' Drop Constraint ' + - FormatIdentifier(Database.SQLDialect, Name); + QuoteIdentifier(DataBase.SQLDialect, Name); Query.Prepare; Query.ExecQuery; IndexDefs.Updated := False; @@ -529,11 +538,13 @@ var Query.SQL.Text := 'Select RDB$CONSTRAINT_NAME from RDB$RELATION_CONSTRAINTS ' + 'where RDB$RELATION_NAME = ' + '''' + - FormatIdentifierValue(Database.SQLDialect, FTableName) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''' ' + 'AND RDB$INDEX_NAME = ' + '''' + - FormatIdentifierValue(Database.SQLDialect, Name) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, Name)) + ''' ' + 'AND RDB$CONSTRAINT_TYPE = ''PRIMARY KEY'''; Query.Prepare; @@ -542,9 +553,9 @@ var begin Query.Close; Query.SQL.Text := 'Alter Table ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' Drop Constraint ' + - FormatIdentifier(Database.SQLDialect, Query.Current.ByName('RDB$CONSTRAINT_NAME').AsString); + QuoteIdentifier(DataBase.SQLDialect, Query.Current.ByName('RDB$CONSTRAINT_NAME').AsString); Query.Prepare; Query.ExecQuery; IndexDefs.Updated := False; @@ -646,7 +657,8 @@ begin 'I.RDB$SEGMENT_COUNT, S.RDB$FIELD_NAME from RDB$INDICES I, ' + {do not localize} 'RDB$INDEX_SEGMENTS S where I.RDB$INDEX_NAME = S.RDB$INDEX_NAME '+ {do not localize} 'and I.RDB$RELATION_NAME = ' + '''' + {do not localize} - FormatIdentifierValue(Database.SQLDialect, FTableName) + ''''; + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''''; Query.Prepare; Query.ExecQuery; while (not Query.EOF) and (Query.Next <> nil) do @@ -670,7 +682,8 @@ begin SubQuery.SQL.Text := 'Select RDB$FIELD_NAME from RDB$INDEX_SEGMENTS where RDB$INDEX_NAME = ' + {do not localize} '''' + - FormatIdentifierValue(Database.SQLDialect, Name) + + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, Name)) + '''' + 'ORDER BY RDB$FIELD_POSITION'; {do not localize} SubQuery.Prepare; SubQuery.ExecQuery; @@ -716,7 +729,8 @@ begin Query.SQL.Text := 'Select USER from RDB$RELATIONS where RDB$RELATION_NAME = ' + {do not localize} '''' + - FormatIdentifierValue(Database.SQLDialect, FTableName) + ''''; + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''''; Query.Prepare; Query.ExecQuery; Result := not Query.EOF; @@ -758,23 +772,23 @@ var case DataType of ftString: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' VARCHAR(' + IntToStr(Size) + ')'; {do not localize} ftFixedChar: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' CHAR(' + IntToStr(Size) + ')'; {do not localize} ftBoolean, ftSmallint, ftWord: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' SMALLINT'; {do not localize} ftInteger: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' INTEGER'; {do not localize} ftFloat, ftCurrency: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' DOUBLE PRECISION'; {do not localize} ftBCD: begin if (Database.SQLDialect = 1) then begin @@ -785,44 +799,44 @@ var end; if (Precision <= 4 ) then FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' Numeric(18, 4)' {do not localize} else FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' Numeric(' + IntToStr(Precision) + ', 4)'; {do not localize} end; ftDate: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' DATE'; {do not localize} ftTime: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' TIME'; {do not localize} ftDateTime: if (Database.SQLDialect = 1) then FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' DATE' {do not localize} else FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' TIMESTAMP'; {do not localize} ftLargeInt: if (Database.SQLDialect = 1) then IBError(ibxeFieldUnsupportedType,[nil]) else FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' Numeric(18, 0)'; {do not localize} ftBlob, ftMemo: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' BLOB SUB_TYPE 1'; {do not localize} ftBytes, ftVarBytes, ftGraphic..ftTypedBinary: FieldList := FieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' BLOB SUB_TYPE 0'; {do not localize} ftUnknown, ftADT, ftArray, ftReference, ftDataSet, ftCursor, ftWideString, ftAutoInc: @@ -848,14 +862,14 @@ var Query.Database := Database; Query.transaction := Transaction; Query.SQL.Text := 'Create Table ' + - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' (' + FieldList; {do not localize} for I := 0 to IndexDefs.Count - 1 do with IndexDefs[I] do if ixPrimary in Options then begin Query.SQL.Text := Query.SQL.Text + ', CONSTRAINT ' + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' Primary Key (' + FormatFieldsList(Fields) + ')'; @@ -895,7 +909,7 @@ begin Query.Database := DataBase; Query.Transaction := Transaction; Query.SQL.Text := 'drop table ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName); + QuoteIdentifier(DataBase.SQLDialect, FTableName); Query.Prepare; Query.ExecQuery; finally @@ -914,7 +928,7 @@ begin Query.Database := DataBase; Query.Transaction := Transaction; Query.SQL.Text := 'delete from ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName); + QuoteIdentifier(DataBase.SQLDialect, FTableName); Query.Prepare; Query.ExecQuery; if Active then @@ -927,7 +941,7 @@ begin end; end; -procedure TIBTable.DataEvent(Event: TDataEvent; Info: Longint); +procedure TIBTable.DataEvent(Event: TDataEvent; Info: Ptrint); begin if Event = dePropertyChange then begin IndexDefs.Updated := False; @@ -958,7 +972,8 @@ begin Query.SQL.Text := 'Select RDB$SYSTEM_FLAG, RDB$DBKEY_LENGTH ' + {do not localize} 'from RDB$RELATIONS where RDB$RELATION_NAME = ' + {do not localize} '''' + - FormatIdentifierValue(Database.SQLDialect, FTableName) + ''''; + FormatIdentifierValue(Database.SQLDialect, + QuoteIdentifier(DataBase.SQLDialect, FTableName)) + ''''; Query.Prepare; Query.ExecQuery; if (Query.Current[0].AsInteger <> 0) or @@ -1048,7 +1063,7 @@ var i: Integer; begin if Database.SQLDialect = 1 then begin - Value := FormatIdentifier(Database.SQLDialect, Value); + Value := QuoteIdentifier(Database.SQLDialect, Value); Result := StringReplace (Value, ';', ', ', [rfReplaceAll]); end else begin @@ -1058,9 +1073,9 @@ begin begin FieldName := ExtractFieldName(Value, i); if Result = '' then - Result := FormatIdentifier(Database.SQLDialect, FieldName) + Result := QuoteIdentifier(Database.SQLDialect, FieldName) else - Result := Result + ', ' + FormatIdentifier(Database.SQLDialect, FieldName); + Result := Result + ', ' + QuoteIdentifier(Database.SQLDialect, FieldName); end; end; end; @@ -1293,9 +1308,9 @@ begin OrderByStr := FormatFieldsList(FPrimaryIndexFields); SQL := TStringList.Create; SQL.Text := 'select ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + '.*, ' + QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize} + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize} - + FormatIdentifier(Database.SQLDialect, FTableName); + + QuoteIdentifier(DataBase.SQLDialect, FTableName); if Filtered and (Filter <> '') then begin SQL.Text := SQL.Text + ' where ' + Filter; {do not localize} @@ -1315,18 +1330,18 @@ begin if i > 0 then SQL.Text := SQL.Text + 'AND '; SQL.Text := SQL.Text + - FormatIdentifier(Database.SQLDialect, FDetailFieldsList.Strings[i]) + + QuoteIdentifier(DataBase.SQLDialect, FDetailFieldsList.Strings[i]) + ' = :' + - FormatIdentifier(Database.SQLDialect, FMasterFieldsList.Strings[i]); + QuoteIdentifier(DataBase.SQLDialect, FMasterFieldsList.Strings[i]); end; end; if OrderByStr <> '' then SQL.Text := SQL.Text + ' order by ' + OrderByStr; {do not localize} SelectSQL.Assign(SQL); RefreshSQL.Text := 'select ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + '.*, ' + QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize} + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize} - + FormatIdentifier(Database.SQLDialect, FTableName) + + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' where RDB$DB_KEY = :IBX_INTERNAL_DBKEY'; {do not localize} WhereDBKeyRefreshSQL.Assign(RefreshSQL); InternalPrepare; @@ -1355,17 +1370,17 @@ var WhereAllFieldList := WhereAllFieldList + ' AND '; end; InsertFieldList := InsertFieldList + - FormatIdentifier(Database.SQLDialect, Name); + QuoteIdentifier(DataBase.SQLDialect, Name); InsertParamList := InsertParamList + ':' + - FormatIdentifier(Database.SQLDialect, Name); + QuoteIdentifier(DataBase.SQLDialect, Name); UpdateFieldList := UpdateFieldList + - FormatIdentifier(Database.SQLDialect, Name) + + QuoteIdentifier(DataBase.SQLDialect, Name) + ' = :' + - FormatIdentifier(Database.SQLDialect, Name); + QuoteIdentifier(DataBase.SQLDialect, Name); if (DataType <> ftBlob) and (DataType <>ftMemo) then WhereAllFieldList := WhereAllFieldList + - FormatIdentifier(Database.SQLDialect, Name) + ' = :' + - FormatIdentifier(Database.SQLDialect, Name);{do not localize} + QuoteIdentifier(DataBase.SQLDialect, Name) + ' = :' + + QuoteIdentifier(DataBase.SQLDialect, Name);{do not localize} end; end; end; @@ -1381,8 +1396,8 @@ var begin tmp := ExtractFieldName(FPrimaryIndexFields, i); tmp := - FormatIdentifier(Database.SQLDialect, tmp) + ' = :' + - FormatIdentifier(Database.SQLDialect, tmp);{do not localize} + QuoteIdentifier(DataBase.SQLDialect, tmp) + ' = :' + + QuoteIdentifier(DataBase.SQLDialect, tmp);{do not localize} if WherePrimaryFieldList <> '' then WherePrimaryFieldList := WherePrimaryFieldList + ' AND ' + tmp @@ -1397,29 +1412,29 @@ begin else begin DeleteSQL.Text := 'delete from ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' where RDB$DB_KEY = ' + ':IBX_INTERNAL_DBKEY'; {do not localize} GenerateFieldLists; InsertSQL.Text := 'insert into ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' (' + InsertFieldList + {do not localize} ') values (' + InsertParamList + ')'; {do not localize} ModifySQL.Text := 'update ' + - FormatIdentifier(Database.SQLDialect, FTableName) + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' set ' + UpdateFieldList + {do not localize} ' where RDB$DB_KEY = :IBX_INTERNAL_DBKEY'; {do not localize} WhereAllRefreshSQL.Text := 'select ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + '.*, ' + QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize} - + FormatIdentifier(Database.SQLDialect, FTableName) + + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' where ' + WhereAllFieldList; {do not localize} if FPrimaryIndexFields <> '' then begin GenerateWherePrimaryFieldList; WherePrimaryRefreshSQL.Text := 'select ' + {do not localize} - FormatIdentifier(Database.SQLDialect, FTableName) + '.*, ' {do not localize} + QuoteIdentifier(DataBase.SQLDialect, FTableName) + '.*, ' {do not localize} + 'RDB$DB_KEY as IBX_INTERNAL_DBKEY from ' {do not localize} - + FormatIdentifier(Database.SQLDialect, FTableName) + + + QuoteIdentifier(DataBase.SQLDialect, FTableName) + ' where ' + WherePrimaryFieldList; {do not localize} end; try @@ -1499,7 +1514,7 @@ begin begin SetState(dsInactive); CloseCursor; - OpenCursor; + OpenCursor(false); SetState(dsBrowse); end; finally @@ -1507,104 +1522,4 @@ begin end; end; -{ TIBTable IProviderSupport } - -function TIBTable.PSGetDefaultOrder: TIndexDef; - - function GetIdx(IdxType: TIndexOption): TIndexDef; - var - i: Integer; - begin - Result := nil; - for i := 0 to IndexDefs.Count - 1 do - if IdxType in IndexDefs[i].Options then - try - Result := IndexDefs[i]; - GetFieldList(nil, Result.Fields); - break; - except - Result := nil; - end; - end; - -var - DefIdx: TIndexDef; -begin - DefIdx := nil; - IndexDefs.Update; - try - if IndexName <> '' then - DefIdx := IndexDefs.Find(IndexName) - else if IndexFieldNames <> '' then - DefIdx := IndexDefs.FindIndexForFields(IndexFieldNames); - if Assigned(DefIdx) then - GetFieldList(nil, DefIdx.Fields); - except - DefIdx := nil; - end; - if not Assigned(DefIdx) then - DefIdx := GetIdx(ixPrimary); - if not Assigned(DefIdx) then - DefIdx := GetIdx(ixUnique); - if Assigned(DefIdx) then - begin - Result := TIndexDef.Create(nil); - Result.Assign(DefIdx); - end else - Result := nil; -end; - -function TIBTable.PSGetIndexDefs(IndexTypes: TIndexOptions): TIndexDefs; -begin - Result := GetIndexDefs(IndexDefs, IndexTypes); -end; - -function TIBTable.PSGeTTableName: string; -begin - Result := FTableName; -end; - -procedure TIBTable.PSSetParams(AParams: TParams); -begin - if AParams.Count > 0 then - Open; - PSReset; -end; - -procedure TIBTable.PSSetCommandText(const CommandText: string); -begin - if CommandText <> '' then - TableName := CommandText; -end; - -function TIBTable.PSGetKeyFields: string; -var - i, Idx: Integer; - IndexFound: Boolean; -begin - Result := inherited PSGetKeyFields; - if Result = '' then - begin - if not Exists then Exit; - IndexFound := False; - IndexDefs.Update; - FieldDefs.Update; - for i := 0 to IndexDefs.Count - 1 do - if ixUnique in IndexDefs[I].Options then - begin - Idx := 1; - Result := IndexDefs[I].Fields; - IndexFound := False; - while Idx <= Length(Result) do - begin - IndexFound := FindField(ExtractFieldName(Result, Idx)) <> nil; - if not IndexFound then Break; - end; - if IndexFound then Break; - end; - if not IndexFound then - Result := ''; - end; -end; - end.