db.pp 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
  4. Free Pascal development team
  5. DB header file with interface section.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit db;
  13. {$mode objfpc}
  14. {$h+}
  15. interface
  16. uses Classes,Sysutils,Variants;
  17. const
  18. dsMaxBufferCount = MAXINT div 8;
  19. dsMaxStringSize = 8192;
  20. // Used in AsBoolean for string fields to determine
  21. // whether it's true or false.
  22. YesNoChars : Array[Boolean] of char = ('Y','N');
  23. SQLDelimiterCharacters = [';',',',' ','(',')',#13,#10,#9];
  24. type
  25. {LargeInt}
  26. LargeInt = Int64;
  27. { Auxiliary type }
  28. TStringFieldBuffer = Array[0..dsMaxStringSize] of Char;
  29. { Misc Dataset types }
  30. TDataSetState = (dsInactive, dsBrowse, dsEdit, dsInsert, dsSetKey,
  31. dsCalcFields, dsFilter, dsNewValue, dsOldValue, dsCurValue, dsBlockRead,
  32. dsInternalCalc, dsOpening);
  33. TDataEvent = (deFieldChange, deRecordChange, deDataSetChange,
  34. deDataSetScroll, deLayoutChange, deUpdateRecord, deUpdateState,
  35. deCheckBrowseMode, dePropertyChange, deFieldListChange, deFocusControl,
  36. deParentScroll);
  37. TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);
  38. TUpdateStatusSet = SET OF TUpdateStatus;
  39. TUpdateMode = (upWhereAll, upWhereChanged, upWhereKeyOnly);
  40. TProviderFlag = (pfInUpdate, pfInWhere, pfInKey, pfHidden);
  41. TProviderFlags = set of TProviderFlag;
  42. { Forward declarations }
  43. TFieldDef = class;
  44. TFieldDefs = class;
  45. TField = class;
  46. TFields = Class;
  47. TDataSet = class;
  48. TDataBase = Class;
  49. TDatasource = Class;
  50. TDatalink = Class;
  51. TDBTransaction = Class;
  52. { Exception classes }
  53. EDatabaseError = class(Exception);
  54. { TFieldDef }
  55. TFieldClass = class of TField;
  56. {
  57. TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
  58. ftBoolean, ftFloat, ftDate, ftTime, ftDateTime,
  59. ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
  60. ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor);
  61. }
  62. TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
  63. ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,
  64. ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo,
  65. ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar,
  66. ftWideString, ftLargeint, ftADT, ftArray, ftReference,
  67. ftDataSet, ftOraBlob, ftOraClob, ftVariant, ftInterface,
  68. ftIDispatch, ftGuid, ftTimeStamp, ftFMTBcd);
  69. { TDateTimeRec }
  70. TDateTimeAlias = type TDateTime;
  71. TDateTimeRec = record
  72. case TFieldType of
  73. ftDate: (Date: Longint);
  74. ftTime: (Time: Longint);
  75. ftDateTime: (DateTime: TDateTimeAlias);
  76. end;
  77. TFieldAttribute = (faHiddenCol, faReadonly, faRequired, faLink, faUnNamed, faFixed);
  78. TFieldAttributes = set of TFieldAttribute;
  79. { TFieldDef }
  80. TFieldDef = class(TCollectionItem)
  81. Private
  82. FDataType : TFieldType;
  83. FFieldNo : Longint;
  84. FInternalCalcField : Boolean;
  85. FPrecision : Longint;
  86. FRequired : Boolean;
  87. FSize : Word;
  88. FName : String;
  89. FDisplayName : String;
  90. FAttributes : TFieldAttributes;
  91. Function GetFieldClass : TFieldClass;
  92. procedure SetAttributes(AValue: TFieldAttributes);
  93. procedure SetDataType(AValue: TFieldType);
  94. procedure SetPrecision(const AValue: Longint);
  95. procedure SetSize(const AValue: Word);
  96. procedure SetRequired(const AValue: Boolean);
  97. protected
  98. function GetDisplayName: string; override;
  99. procedure SetDisplayName(const AValue: string); override;
  100. public
  101. constructor Create(AOwner: TFieldDefs; const AName: string;
  102. ADataType: TFieldType; ASize: Word; ARequired: Boolean; AFieldNo: Longint);
  103. destructor Destroy; override;
  104. procedure Assign(APersistent: TPersistent); override;
  105. function CreateField(AOwner: TComponent): TField;
  106. property FieldClass: TFieldClass read GetFieldClass;
  107. property FieldNo: Longint read FFieldNo;
  108. property InternalCalcField: Boolean read FInternalCalcField write FInternalCalcField;
  109. property Required: Boolean read FRequired write SetRequired;
  110. Published
  111. property Attributes: TFieldAttributes read FAttributes write SetAttributes default [];
  112. property Name: string read FName write FName; // Must move to TNamedItem
  113. property DisplayName : string read FDisplayName write FDisplayName; // Must move to TNamedItem
  114. property DataType: TFieldType read FDataType write SetDataType;
  115. property Precision: Longint read FPrecision write SetPrecision;
  116. property Size: Word read FSize write SetSize;
  117. end;
  118. { TFieldDefs }
  119. TFieldDefs = class(TOwnedCollection)
  120. private
  121. FUpdated: Boolean;
  122. FHiddenFields : Boolean;
  123. function GetItem(Index: Longint): TFieldDef;
  124. function GetDataset: TDataset;
  125. procedure SetItem(Index: Longint; const AValue: TFieldDef);
  126. protected
  127. procedure SetItemName(AItem: TCollectionItem); override;
  128. public
  129. constructor Create(ADataSet: TDataSet);
  130. // destructor Destroy; override;
  131. procedure Add(const AName: string; ADataType: TFieldType; ASize: Word; ARequired: Boolean);
  132. procedure Add(const AName: string; ADataType: TFieldType; ASize: Word);
  133. procedure Add(const AName: string; ADataType: TFieldType);
  134. Function AddFieldDef : TFieldDef;
  135. procedure Assign(FieldDefs: TFieldDefs);
  136. // procedure Clear;
  137. // procedure Delete(Index: Longint);
  138. function Find(const AName: string): TFieldDef;
  139. function IndexOf(const AName: string): Longint;
  140. procedure Update;
  141. Property HiddenFields : Boolean Read FHiddenFields Write FHiddenFields;
  142. property Items[Index: Longint]: TFieldDef read GetItem write SetItem; default;
  143. property Dataset: TDataset read GetDataset;
  144. property Updated: Boolean read FUpdated write FUpdated;
  145. end;
  146. { TField }
  147. TFieldKind = (fkData, fkCalculated, fkLookup, fkInternalCalc);
  148. TFieldKinds = Set of TFieldKind;
  149. TFieldNotifyEvent = procedure(Sender: TField) of object;
  150. TFieldGetTextEvent = procedure(Sender: TField; var Text: string;
  151. DisplayText: Boolean) of object;
  152. TFieldSetTextEvent = procedure(Sender: TField; const Text: string) of object;
  153. TFieldRef = ^TField;
  154. TFieldChars = set of Char;
  155. PLookupListRec = ^TLookupListRec;
  156. TLookupListRec = record
  157. Key: Variant;
  158. Value: Variant;
  159. end;
  160. { TLookupList }
  161. TLookupList = class(TObject)
  162. private
  163. FList: TList;
  164. public
  165. constructor Create;
  166. destructor Destroy; override;
  167. procedure Add(const AKey, AValue: Variant);
  168. procedure Clear;
  169. function ValueOfKey(const AKey: Variant): Variant;
  170. end;
  171. { TField }
  172. TField = class(TComponent)
  173. Private
  174. FAlignMent : TAlignment;
  175. FAttributeSet : String;
  176. FCalculated : Boolean;
  177. FConstraintErrorMessage : String;
  178. FCustomConstraint : String;
  179. FDataSet : TDataSet;
  180. // FDataSize : Word;
  181. FDataType : TFieldType;
  182. FDefaultExpression : String;
  183. FDisplayLabel : String;
  184. FDisplayWidth : Longint;
  185. FFieldKind : TFieldKind;
  186. FFieldName : String;
  187. FFieldNo : Longint;
  188. FFields : TFields;
  189. FHasConstraints : Boolean;
  190. FImportedConstraint : String;
  191. FIsIndexField : Boolean;
  192. FKeyFields : String;
  193. FLookupCache : Boolean;
  194. FLookupDataSet : TDataSet;
  195. FLookupKeyfields : String;
  196. FLookupresultField : String;
  197. FLookupList: TLookupList;
  198. FOffset : Word;
  199. FOnChange : TFieldNotifyEvent;
  200. FOnGetText: TFieldGetTextEvent;
  201. FOnSetText: TFieldSetTextEvent;
  202. FOnValidate: TFieldNotifyEvent;
  203. FOrigin : String;
  204. FReadOnly : Boolean;
  205. FRequired : Boolean;
  206. FSize : Word;
  207. FValidChars : TFieldChars;
  208. FValueBuffer : Pointer;
  209. FValidating : Boolean;
  210. FVisible : Boolean;
  211. FProviderFlags : TProviderFlags;
  212. Function GetIndex : longint;
  213. procedure SetAlignment(const AValue: TAlignMent);
  214. procedure SetIndex(AValue: Integer);
  215. Procedure SetDataset(AValue : TDataset);
  216. function GetDisplayText: String;
  217. function GetEditText: String;
  218. procedure SetEditText(const AValue: string);
  219. procedure SetDisplayLabel(const AValue: string);
  220. procedure SetDisplayWidth(const AValue: Longint);
  221. function GetDisplayWidth: integer;
  222. procedure SetReadOnly(const AValue: Boolean);
  223. procedure SetVisible(const AValue: Boolean);
  224. function IsDisplayStored : Boolean;
  225. function GetLookupList: TLookupList;
  226. procedure CalcLookupValue;
  227. protected
  228. function AccessError(const TypeName: string): EDatabaseError;
  229. procedure CheckInactive;
  230. class procedure CheckTypeSize(AValue: Longint); virtual;
  231. procedure Change; virtual;
  232. procedure DataChanged;
  233. procedure FreeBuffers; virtual;
  234. function GetAsBoolean: Boolean; virtual;
  235. function GetAsCurrency: Currency; virtual;
  236. function GetAsDateTime: TDateTime; virtual;
  237. function GetAsFloat: Double; virtual;
  238. function GetAsLongint: Longint; virtual;
  239. function GetAsInteger: Longint; virtual;
  240. function GetAsVariant: variant; virtual;
  241. function GetOldValue: variant; virtual;
  242. function GetAsString: string; virtual;
  243. function GetCanModify: Boolean; virtual;
  244. function GetDataSize: Word; virtual;
  245. function GetDefaultWidth: Longint; virtual;
  246. function GetDisplayName : String;
  247. function GetCurValue: Variant; virtual;
  248. function GetNewValue: Variant; virtual;
  249. function GetIsNull: Boolean; virtual;
  250. function GetParentComponent: TComponent; override;
  251. procedure GetText(var AText: string; ADisplayText: Boolean); virtual;
  252. function HasParent: Boolean; override;
  253. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  254. procedure PropertyChanged(LayoutAffected: Boolean);
  255. procedure ReadState(Reader: TReader); override;
  256. procedure SetAsBoolean(AValue: Boolean); virtual;
  257. procedure SetAsCurrency(AValue: Currency); virtual;
  258. procedure SetAsDateTime(AValue: TDateTime); virtual;
  259. procedure SetAsFloat(AValue: Double); virtual;
  260. procedure SetAsLongint(AValue: Longint); virtual;
  261. procedure SetAsInteger(AValue: Integer); virtual;
  262. procedure SetAsVariant(AValue: variant); virtual;
  263. procedure SetAsString(const AValue: string); virtual;
  264. procedure SetDataType(AValue: TFieldType);
  265. procedure SetNewValue(const AValue: Variant);
  266. procedure SetSize(AValue: Word); virtual;
  267. procedure SetParentComponent(AParent: TComponent); override;
  268. procedure SetText(const AValue: string); virtual;
  269. procedure SetVarValue(const AValue: Variant); virtual;
  270. public
  271. constructor Create(AOwner: TComponent); override;
  272. destructor Destroy; override;
  273. procedure Assign(Source: TPersistent); override;
  274. procedure AssignValue(const AValue: TVarRec);
  275. procedure Clear; virtual;
  276. procedure FocusControl;
  277. function GetData(Buffer: Pointer): Boolean;
  278. function GetData(Buffer: Pointer; NativeFormat : Boolean): Boolean;
  279. class function IsBlob: Boolean; virtual;
  280. function IsValidChar(InputChar: Char): Boolean; virtual;
  281. procedure RefreshLookupList;
  282. procedure SetData(Buffer: Pointer);
  283. procedure SetData(Buffer: Pointer; NativeFormat : Boolean);
  284. procedure SetFieldType(AValue: TFieldType); virtual;
  285. procedure Validate(Buffer: Pointer);
  286. property AsBoolean: Boolean read GetAsBoolean write SetAsBoolean;
  287. property AsCurrency: Currency read GetAsCurrency write SetAsCurrency;
  288. property AsDateTime: TDateTime read GetAsDateTime write SetAsDateTime;
  289. property AsFloat: Double read GetAsFloat write SetAsFloat;
  290. property AsLongint: Longint read GetAsLongint write SetAsLongint;
  291. property AsInteger: Integer read GetAsInteger write SetAsInteger;
  292. property AsString: string read GetAsString write SetAsString;
  293. property AsVariant: variant read GetAsVariant write SetAsVariant;
  294. property AttributeSet: string read FAttributeSet write FAttributeSet;
  295. property Calculated: Boolean read FCalculated write FCalculated;
  296. property CanModify: Boolean read GetCanModify;
  297. property CurValue: Variant read GetCurValue;
  298. property DataSet: TDataSet read FDataSet write SetDataSet;
  299. property DataSize: Word read GetDataSize;
  300. property DataType: TFieldType read FDataType;
  301. property DisplayName: String Read GetDisplayName;
  302. property DisplayText: String read GetDisplayText;
  303. property FieldNo: Longint read FFieldNo;
  304. property IsIndexField: Boolean read FIsIndexField;
  305. property IsNull: Boolean read GetIsNull;
  306. property NewValue: Variant read GetNewValue write SetNewValue;
  307. property Offset: word read FOffset;
  308. property Size: Word read FSize write FSize;
  309. property Text: string read GetEditText write SetEditText;
  310. property ValidChars : TFieldChars Read FValidChars;
  311. property Value: variant read GetAsVariant write SetAsVariant;
  312. property OldValue: variant read GetOldValue;
  313. property LookupList: TLookupList read GetLookupList;
  314. published
  315. property AlignMent : TAlignMent Read FAlignMent write SetAlignment default taLeftJustify;
  316. property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
  317. property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
  318. property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
  319. property DisplayLabel : string read GetDisplayName write SetDisplayLabel stored IsDisplayStored;
  320. property DisplayWidth: Longint read GetDisplayWidth write SetDisplayWidth;
  321. property FieldKind: TFieldKind read FFieldKind write FFieldKind;
  322. property FieldName: string read FFieldName write FFieldName;
  323. property HasConstraints: Boolean read FHasConstraints;
  324. property Index: Longint read GetIndex write SetIndex;
  325. property ImportedConstraint: string read FImportedConstraint write FImportedConstraint;
  326. property LookupDataSet: TDataSet read FLookupDataSet write FLookupDataSet;
  327. property LookupKeyFields: string read FLookupKeyFields write FLookupKeyFields;
  328. property LookupResultField: string read FLookupResultField write FLookupResultField;
  329. property KeyFields: string read FKeyFields write FKeyFields;
  330. property LookupCache: Boolean read FLookupCache write FLookupCache;
  331. property Origin: string read FOrigin write FOrigin;
  332. property ProviderFlags : TProviderFlags read FProviderFlags write FProviderFlags;
  333. property ReadOnly: Boolean read FReadOnly write SetReadOnly;
  334. property Required: Boolean read FRequired write FRequired;
  335. property Visible: Boolean read FVisible write SetVisible default True;
  336. property OnChange: TFieldNotifyEvent read FOnChange write FOnChange;
  337. property OnGetText: TFieldGetTextEvent read FOnGetText write FOnGetText;
  338. property OnSetText: TFieldSetTextEvent read FOnSetText write FOnSetText;
  339. property OnValidate: TFieldNotifyEvent read FOnValidate write FOnValidate;
  340. end;
  341. { TStringField }
  342. TStringField = class(TField)
  343. protected
  344. class procedure CheckTypeSize(AValue: Longint); override;
  345. function GetAsBoolean: Boolean; override;
  346. function GetAsDateTime: TDateTime; override;
  347. function GetAsFloat: Double; override;
  348. function GetAsLongint: Longint; override;
  349. function GetAsString: string; override;
  350. function GetAsVariant: variant; override;
  351. function GetDataSize: Word; override;
  352. function GetDefaultWidth: Longint; override;
  353. procedure GetText(var AText: string; ADisplayText: Boolean); override;
  354. function GetValue(var AValue: string): Boolean;
  355. procedure SetAsBoolean(AValue: Boolean); override;
  356. procedure SetAsDateTime(AValue: TDateTime); override;
  357. procedure SetAsFloat(AValue: Double); override;
  358. procedure SetAsLongint(AValue: Longint); override;
  359. procedure SetAsString(const AValue: string); override;
  360. procedure SetVarValue(const AValue: Variant); override;
  361. public
  362. constructor Create(AOwner: TComponent); override;
  363. published
  364. property Size default 20;
  365. end;
  366. { TNumericField }
  367. TNumericField = class(TField)
  368. Private
  369. FDisplayFormat : String;
  370. FEditFormat : String;
  371. protected
  372. procedure RangeError(AValue, Min, Max: Double);
  373. procedure SetDisplayFormat(const AValue: string);
  374. procedure SetEditFormat(const AValue: string);
  375. public
  376. constructor Create(AOwner: TComponent); override;
  377. published
  378. property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
  379. property EditFormat: string read FEditFormat write SetEditFormat;
  380. end;
  381. { TLongintField }
  382. TLongintField = class(TNumericField)
  383. private
  384. FMinValue,
  385. FMaxValue,
  386. FMinRange,
  387. FMAxRange : Longint;
  388. Procedure SetMinValue (AValue : longint);
  389. Procedure SetMaxValue (AValue : longint);
  390. protected
  391. function GetAsFloat: Double; override;
  392. function GetAsLongint: Longint; override;
  393. function GetAsString: string; override;
  394. function GetAsVariant: variant; override;
  395. function GetDataSize: Word; override;
  396. procedure GetText(var AText: string; ADisplayText: Boolean); override;
  397. function GetValue(var AValue: Longint): Boolean;
  398. procedure SetAsFloat(AValue: Double); override;
  399. procedure SetAsLongint(AValue: Longint); override;
  400. procedure SetAsString(const AValue: string); override;
  401. procedure SetVarValue(const AValue: Variant); override;
  402. public
  403. constructor Create(AOwner: TComponent); override;
  404. Function CheckRange(AValue : longint) : Boolean;
  405. property Value: Longint read GetAsLongint write SetAsLongint;
  406. published
  407. property MaxValue: Longint read FMaxValue write SetMaxValue default 0;
  408. property MinValue: Longint read FMinValue write SetMinValue default 0;
  409. end;
  410. TIntegerField = TLongintField;
  411. { TLargeintField }
  412. TLargeintField = class(TNumericField)
  413. private
  414. FMinValue,
  415. FMaxValue,
  416. FMinRange,
  417. FMAxRange : Largeint;
  418. Procedure SetMinValue (AValue : Largeint);
  419. Procedure SetMaxValue (AValue : Largeint);
  420. protected
  421. function GetAsFloat: Double; override;
  422. function GetAsLongint: Longint; override;
  423. function GetAsLargeint: Largeint; virtual;
  424. function GetAsString: string; override;
  425. function GetAsVariant: variant; override;
  426. function GetDataSize: Word; override;
  427. procedure GetText(var AText: string; ADisplayText: Boolean); override;
  428. function GetValue(var AValue: Largeint): Boolean;
  429. procedure SetAsFloat(AValue: Double); override;
  430. procedure SetAsLongint(AValue: Longint); override;
  431. procedure SetAsLargeint(AValue: Largeint); virtual;
  432. procedure SetAsString(const AValue: string); override;
  433. procedure SetVarValue(const AValue: Variant); override;
  434. public
  435. constructor Create(AOwner: TComponent); override;
  436. Function CheckRange(AValue : largeint) : Boolean;
  437. property Value: Longint read GetAsLongint write SetAsLongint;
  438. property AsLargeInt: LargeInt read GetAsLargeint write SetAsLargeint;
  439. published
  440. property MaxValue: Largeint read FMaxValue write SetMaxValue default 0;
  441. property MinValue: Largeint read FMinValue write SetMinValue default 0;
  442. end;
  443. { TSmallintField }
  444. TSmallintField = class(TLongintField)
  445. protected
  446. function GetDataSize: Word; override;
  447. public
  448. constructor Create(AOwner: TComponent); override;
  449. end;
  450. { TWordField }
  451. TWordField = class(TLongintField)
  452. protected
  453. function GetDataSize: Word; override;
  454. public
  455. constructor Create(AOwner: TComponent); override;
  456. end;
  457. { TAutoIncField }
  458. TAutoIncField = class(TLongintField)
  459. Protected
  460. Procedure SetAsLongInt(AValue : Longint); override;
  461. public
  462. constructor Create(AOwner: TComponent); override;
  463. end;
  464. { TFloatField }
  465. TFloatField = class(TNumericField)
  466. private
  467. FMaxValue : Double;
  468. FMinValue : Double;
  469. FPrecision : Longint;
  470. protected
  471. function GetAsFloat: Double; override;
  472. function GetAsLongint: Longint; override;
  473. function GetAsVariant: variant; override;
  474. function GetAsString: string; override;
  475. function GetDataSize: Word; override;
  476. procedure GetText(var theText: string; ADisplayText: Boolean); override;
  477. procedure SetAsFloat(AValue: Double); override;
  478. procedure SetAsLongint(AValue: Longint); override;
  479. procedure SetAsString(const AValue: string); override;
  480. procedure SetVarValue(const AValue: Variant); override;
  481. public
  482. constructor Create(AOwner: TComponent); override;
  483. Function CheckRange(AValue : Double) : Boolean;
  484. property Value: Double read GetAsFloat write SetAsFloat;
  485. published
  486. property MaxValue: Double read FMaxValue write FMaxValue;
  487. property MinValue: Double read FMinValue write FMinValue;
  488. property Precision: Longint read FPrecision write FPrecision default 15;
  489. end;
  490. { TCurrencyField }
  491. TCurrencyField = class(TFloatField)
  492. public
  493. constructor Create(AOwner: TComponent); override;
  494. procedure GetText(var TheText: string; ADisplayText: Boolean); override;
  495. end;
  496. { TBooleanField }
  497. TBooleanField = class(TField)
  498. private
  499. FDisplayValues : String;
  500. // First byte indicates uppercase or not.
  501. FDisplays : Array[Boolean,Boolean] of string;
  502. Procedure SetDisplayValues(AValue : String);
  503. protected
  504. function GetAsBoolean: Boolean; override;
  505. function GetAsString: string; override;
  506. function GetAsVariant: variant; override;
  507. function GetDataSize: Word; override;
  508. function GetDefaultWidth: Longint; override;
  509. procedure SetAsBoolean(AValue: Boolean); override;
  510. procedure SetAsString(const AValue: string); override;
  511. procedure SetVarValue(const AValue: Variant); override;
  512. public
  513. constructor Create(AOwner: TComponent); override;
  514. property Value: Boolean read GetAsBoolean write SetAsBoolean;
  515. published
  516. property DisplayValues: string read FDisplayValues write SetDisplayValues;
  517. end;
  518. { TDateTimeField }
  519. TDateTimeField = class(TField)
  520. private
  521. FDisplayFormat : String;
  522. procedure SetDisplayFormat(const AValue: string);
  523. protected
  524. function GetAsDateTime: TDateTime; override;
  525. function GetAsFloat: Double; override;
  526. function GetAsString: string; override;
  527. function GetAsVariant: variant; override;
  528. function GetDataSize: Word; override;
  529. procedure GetText(var theText: string; ADisplayText: Boolean); override;
  530. procedure SetAsDateTime(AValue: TDateTime); override;
  531. procedure SetAsFloat(AValue: Double); override;
  532. procedure SetAsString(const AValue: string); override;
  533. procedure SetVarValue(const AValue: Variant); override;
  534. public
  535. constructor Create(AOwner: TComponent); override;
  536. property Value: TDateTime read GetAsDateTime write SetAsDateTime;
  537. published
  538. property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
  539. end;
  540. { TDateField }
  541. TDateField = class(TDateTimeField)
  542. public
  543. constructor Create(AOwner: TComponent); override;
  544. end;
  545. { TTimeField }
  546. TTimeField = class(TDateTimeField)
  547. protected
  548. procedure SetAsString(const AValue: string); override;
  549. public
  550. constructor Create(AOwner: TComponent); override;
  551. end;
  552. { TBinaryField }
  553. TBinaryField = class(TField)
  554. protected
  555. class procedure CheckTypeSize(AValue: Longint); override;
  556. function GetAsString: string; override;
  557. procedure GetText(var TheText: string; ADisplayText: Boolean); override;
  558. procedure SetAsString(const AValue: string); override;
  559. procedure SetText(const AValue: string); override;
  560. procedure SetVarValue(const AValue: Variant); override;
  561. public
  562. constructor Create(AOwner: TComponent); override;
  563. published
  564. property Size default 16;
  565. end;
  566. { TBytesField }
  567. TBytesField = class(TBinaryField)
  568. protected
  569. function GetDataSize: Word; override;
  570. public
  571. constructor Create(AOwner: TComponent); override;
  572. end;
  573. { TVarBytesField }
  574. TVarBytesField = class(TBytesField)
  575. protected
  576. function GetDataSize: Word; override;
  577. public
  578. constructor Create(AOwner: TComponent); override;
  579. end;
  580. { TBCDField }
  581. TBCDField = class(TNumericField)
  582. private
  583. FMinValue,
  584. FMaxValue : currency;
  585. FPrecision : Longint;
  586. FCurrency : boolean;
  587. protected
  588. class procedure CheckTypeSize(AValue: Longint); override;
  589. function GetAsCurrency: Currency; override;
  590. function GetAsFloat: Double; override;
  591. function GetAsLongint: Longint; override;
  592. function GetAsString: string; override;
  593. function GetValue(var AValue: Currency): Boolean;
  594. function GetAsVariant: variant; override;
  595. function GetDataSize: Word; override;
  596. function GetDefaultWidth: Longint; override;
  597. procedure GetText(var TheText: string; ADisplayText: Boolean); override;
  598. procedure SetAsFloat(AValue: Double); override;
  599. procedure SetAsLongint(AValue: Longint); override;
  600. procedure SetAsString(const AValue: string); override;
  601. procedure SetAsCurrency(AValue: Currency); override;
  602. procedure SetVarValue(const AValue: Variant); override;
  603. public
  604. constructor Create(AOwner: TComponent); override;
  605. Function CheckRange(AValue : Currency) : Boolean;
  606. property Value: Longint read GetAsLongint write SetAsLongint;
  607. published
  608. property Precision: Longint read FPrecision write FPrecision;
  609. property Currency: Boolean read FCurrency write FCurrency;
  610. property MaxValue: Currency read FMaxValue write FMaxValue;
  611. property MinValue: Currency read FMinValue write FMinValue;
  612. property Size default 4;
  613. end;
  614. { TBlobField }
  615. TBlobStreamMode = (bmRead, bmWrite, bmReadWrite);
  616. TBlobType = ftBlob..ftTypedBinary;
  617. TBlobField = class(TField)
  618. private
  619. FBlobSize : Longint;
  620. FBlobType : TBlobType;
  621. FModified : Boolean;
  622. FTransliterate : Boolean;
  623. Function GetBlobStream (Mode : TBlobStreamMode) : TStream;
  624. protected
  625. procedure AssignTo(Dest: TPersistent); override;
  626. procedure FreeBuffers; override;
  627. function GetAsString: string; override;
  628. function GetBlobSize: Longint; virtual;
  629. function GetIsNull: Boolean; override;
  630. procedure GetText(var TheText: string; ADisplayText: Boolean); override;
  631. procedure SetAsString(const AValue: string); override;
  632. procedure SetText(const AValue: string); override;
  633. procedure SetVarValue(const AValue: Variant); override;
  634. public
  635. constructor Create(AOwner: TComponent); override;
  636. procedure Assign(Source: TPersistent); override;
  637. procedure Clear; override;
  638. class function IsBlob: Boolean; override;
  639. procedure LoadFromFile(const FileName: string);
  640. procedure LoadFromStream(Stream: TStream);
  641. procedure SaveToFile(const FileName: string);
  642. procedure SaveToStream(Stream: TStream);
  643. procedure SetFieldType(AValue: TFieldType); override;
  644. property BlobSize: Longint read FBlobSize;
  645. property Modified: Boolean read FModified write FModified;
  646. property Value: string read GetAsString write SetAsString;
  647. property Transliterate: Boolean read FTransliterate write FTransliterate;
  648. published
  649. property BlobType: TBlobType read FBlobType write FBlobType;
  650. property Size default 0;
  651. end;
  652. { TMemoField }
  653. TMemoField = class(TBlobField)
  654. public
  655. constructor Create(AOwner: TComponent); override;
  656. published
  657. property Transliterate default True;
  658. end;
  659. { TGraphicField }
  660. TGraphicField = class(TBlobField)
  661. public
  662. constructor Create(AOwner: TComponent); override;
  663. end;
  664. { TIndexDef }
  665. TIndexDefs = class;
  666. TIndexOption = (ixPrimary, ixUnique, ixDescending, ixCaseInsensitive,
  667. ixExpression, ixNonMaintained);
  668. TIndexOptions = set of TIndexOption;
  669. TIndexDef = class(TCollectionItem)
  670. Private
  671. FExpression : String;
  672. FFields : String;
  673. FName : String;
  674. FOptions : TIndexOptions;
  675. FSource : String;
  676. public
  677. constructor Create(Owner: TIndexDefs; const AName, TheFields: string;
  678. TheOptions: TIndexOptions);
  679. destructor Destroy; override;
  680. property Expression: string read FExpression;
  681. property Fields: string read FFields write FFields;
  682. property Name: string read FName write FName;
  683. property Options: TIndexOptions read FOptions write FOptions;
  684. property Source: string read FSource write FSource;
  685. end;
  686. { TIndexDefs }
  687. TIndexDefs = class(TOwnedCollection)
  688. Private
  689. FUpDated : Boolean;
  690. FDataset : Tdataset;
  691. Function GetItem(Index: Integer): TIndexDef;
  692. Procedure SetItem(Index: Integer; Value: TIndexDef);
  693. public
  694. constructor Create(DataSet: TDataSet); overload;
  695. destructor Destroy; override;
  696. procedure Add(const Name, Fields: string; Options: TIndexOptions);
  697. Function AddIndexDef: TIndexDef;
  698. procedure Assign(IndexDefs: TIndexDefs);
  699. // procedure Clear;
  700. function Find(const IndexName: string): TIndexDef;
  701. function FindIndexForFields(const Fields: string): TIndexDef;
  702. function GetIndexForFields(const Fields: string;
  703. CaseInsensitive: Boolean): TIndexDef;
  704. function IndexOf(const Name: string): Longint;
  705. procedure Update;
  706. // property Count: Longint read FCount;
  707. Property Items[Index: Integer] : TIndexDef read GetItem write SetItem; default;
  708. property Updated: Boolean read FUpdated write FUpdated;
  709. end;
  710. { TCheckConstraint }
  711. TCheckConstraint = class(TCollectionItem)
  712. Private
  713. FCustomConstraint : String;
  714. FErrorMessage : String;
  715. FFromDictionary : Boolean;
  716. FImportedConstraint : String;
  717. public
  718. procedure Assign(Source: TPersistent); override;
  719. // function GetDisplayName: string; override;
  720. published
  721. property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
  722. property ErrorMessage: string read FErrorMessage write FErrorMessage;
  723. property FromDictionary: Boolean read FFromDictionary write FFromDictionary;
  724. property ImportedConstraint: string read FImportedConstraint write FImportedConstraint;
  725. end;
  726. { TCheckConstraints }
  727. TCheckConstraints = class(TCollection)
  728. Private
  729. Function GetItem(Index : Longint) : TCheckConstraint;
  730. Procedure SetItem(index : Longint; Value : TCheckConstraint);
  731. protected
  732. function GetOwner: TPersistent; override;
  733. public
  734. constructor Create(AOwner: TPersistent);
  735. function Add: TCheckConstraint;
  736. property Items[Index: Longint]: TCheckConstraint read GetItem write SetItem; default;
  737. end;
  738. { TFields }
  739. Tfields = Class(TObject)
  740. Private
  741. FDataset : TDataset;
  742. FFieldList : TList;
  743. FOnChange : TNotifyEvent;
  744. FValidFieldKinds : TFieldKinds;
  745. Protected
  746. Procedure Changed;
  747. Procedure CheckfieldKind(Fieldkind : TFieldKind; Field : TField);
  748. Function GetCount : Longint;
  749. Function GetField (Index : longint) : TField;
  750. Procedure SetField(Index: Integer; Value: TField);
  751. Procedure SetFieldIndex (Field : TField;Value : Integer);
  752. Property OnChange : TNotifyEvent Read FOnChange Write FOnChange;
  753. Property ValidFieldKinds : TFieldKinds Read FValidFieldKinds;
  754. Public
  755. Constructor Create(ADataset : TDataset);
  756. Destructor Destroy;override;
  757. Procedure Add(Field : TField);
  758. Procedure CheckFieldName (Const Value : String);
  759. Procedure CheckFieldNames (Const Value : String);
  760. Procedure Clear;
  761. Function FindField (Const Value : String) : TField;
  762. Function FieldByName (Const Value : String) : TField;
  763. Function FieldByNumber(FieldNo : Integer) : TField;
  764. Procedure GetFieldNames (Values : TStrings);
  765. Function IndexOf(Field : TField) : Longint;
  766. procedure Remove(Value : TField);
  767. Property Count : Integer Read GetCount;
  768. Property Dataset : TDataset Read FDataset;
  769. Property Fields [Index : Integer] : TField Read GetField Write SetField; default;
  770. end;
  771. { TDataSet }
  772. TBookmark = Pointer;
  773. TBookmarkStr = string;
  774. PBookmarkFlag = ^TBookmarkFlag;
  775. TBookmarkFlag = (bfCurrent, bfBOF, bfEOF, bfInserted);
  776. PBufferList = ^TBufferList;
  777. TBufferList = array[0..dsMaxBufferCount - 1] of PChar;
  778. TGetMode = (gmCurrent, gmNext, gmPrior);
  779. TGetResult = (grOK, grBOF, grEOF, grError);
  780. TResyncMode = set of (rmExact, rmCenter);
  781. TDataAction = (daFail, daAbort, daRetry);
  782. TUpdateAction = (uaFail, uaAbort, uaSkip, uaRetry, uaApplied);
  783. TUpdateKind = (ukModify, ukInsert, ukDelete);
  784. TLocateOption = (loCaseInsensitive, loPartialKey);
  785. TLocateOptions = set of TLocateOption;
  786. TDataOperation = procedure of object;
  787. TDataSetNotifyEvent = procedure(DataSet: TDataSet) of object;
  788. TDataSetErrorEvent = procedure(DataSet: TDataSet; E: EDatabaseError;
  789. var Action: TDataAction) of object;
  790. TFilterOption = (foCaseInsensitive, foNoPartialCompare);
  791. TFilterOptions = set of TFilterOption;
  792. TFilterRecordEvent = procedure(DataSet: TDataSet;
  793. var Accept: Boolean) of object;
  794. TDatasetClass = Class of TDataset;
  795. TBufferArray = ^pchar;
  796. TDataSet = class(TComponent)
  797. Private
  798. FOpenAfterRead : boolean;
  799. FActiveRecord: Longint;
  800. FAfterCancel: TDataSetNotifyEvent;
  801. FAfterClose: TDataSetNotifyEvent;
  802. FAfterDelete: TDataSetNotifyEvent;
  803. FAfterEdit: TDataSetNotifyEvent;
  804. FAfterInsert: TDataSetNotifyEvent;
  805. FAfterOpen: TDataSetNotifyEvent;
  806. FAfterPost: TDataSetNotifyEvent;
  807. FAfterRefresh: TDataSetNotifyEvent;
  808. FAfterScroll: TDataSetNotifyEvent;
  809. FAutoCalcFields: Boolean;
  810. FBOF: Boolean;
  811. FBeforeCancel: TDataSetNotifyEvent;
  812. FBeforeClose: TDataSetNotifyEvent;
  813. FBeforeDelete: TDataSetNotifyEvent;
  814. FBeforeEdit: TDataSetNotifyEvent;
  815. FBeforeInsert: TDataSetNotifyEvent;
  816. FBeforeOpen: TDataSetNotifyEvent;
  817. FBeforePost: TDataSetNotifyEvent;
  818. FBeforeRefresh: TDataSetNotifyEvent;
  819. FBeforeScroll: TDataSetNotifyEvent;
  820. FBlobFieldCount: Longint;
  821. FBookmarkSize: Longint;
  822. FBuffers : TBufferArray;
  823. FBufferCount: Longint;
  824. FCalcBuffer: PChar;
  825. FCalcFieldsSize: Longint;
  826. FConstraints: TCheckConstraints;
  827. FDisableControlsCount : Integer;
  828. FDisableControlsState : TDatasetState;
  829. FCurrentRecord: Longint;
  830. FDataSources : TList;
  831. FDefaultFields: Boolean;
  832. FEOF: Boolean;
  833. FEnableControlsEvent : TDataEvent;
  834. FFieldList : TFields;
  835. FFieldDefs: TFieldDefs;
  836. FFilterOptions: TFilterOptions;
  837. FFilterText: string;
  838. FFiltered: Boolean;
  839. FFound: Boolean;
  840. FInternalCalcFields: Boolean;
  841. FModified: Boolean;
  842. FOnCalcFields: TDataSetNotifyEvent;
  843. FOnDeleteError: TDataSetErrorEvent;
  844. FOnEditError: TDataSetErrorEvent;
  845. FOnFilterRecord: TFilterRecordEvent;
  846. FOnNewRecord: TDataSetNotifyEvent;
  847. FOnPostError: TDataSetErrorEvent;
  848. FRecordCount: Longint;
  849. FIsUniDirectional: Boolean;
  850. FState : TDataSetState;
  851. Procedure DoInsertAppend(DoAppend : Boolean);
  852. Procedure DoInternalOpen;
  853. Procedure DoInternalClose(DoCheck : Boolean);
  854. Function GetBuffer (Index : longint) : Pchar;
  855. Function GetField (Index : Longint) : TField;
  856. Procedure RegisterDataSource(ADatasource : TDataSource);
  857. Procedure RemoveField (Field : TField);
  858. Procedure SetField (Index : Longint;Value : TField);
  859. Procedure ShiftBuffersForward;
  860. Procedure ShiftBuffersBackward;
  861. Function TryDoing (P : TDataOperation; Ev : TDatasetErrorEvent) : Boolean;
  862. Function GetActive : boolean;
  863. Procedure UnRegisterDataSource(ADatasource : TDatasource);
  864. Procedure UpdateFieldDefs;
  865. protected
  866. procedure RecalcBufListSize;
  867. procedure ActivateBuffers; virtual;
  868. procedure BindFields(Binding: Boolean);
  869. function BookmarkAvailable: Boolean;
  870. procedure CalculateFields(Buffer: PChar); virtual;
  871. procedure CheckActive; virtual;
  872. procedure CheckInactive; virtual;
  873. procedure CheckBiDirectional;
  874. procedure Loaded; override;
  875. procedure ClearBuffers; virtual;
  876. procedure ClearCalcFields(Buffer: PChar); virtual;
  877. procedure CloseBlob(Field: TField); virtual;
  878. procedure CloseCursor; virtual;
  879. procedure CreateFields; virtual;
  880. procedure DataEvent(Event: TDataEvent; Info: Ptrint); virtual;
  881. procedure DestroyFields; virtual;
  882. procedure DoAfterCancel; virtual;
  883. procedure DoAfterClose; virtual;
  884. procedure DoAfterDelete; virtual;
  885. procedure DoAfterEdit; virtual;
  886. procedure DoAfterInsert; virtual;
  887. procedure DoAfterOpen; virtual;
  888. procedure DoAfterPost; virtual;
  889. procedure DoAfterScroll; virtual;
  890. procedure DoAfterRefresh; virtual;
  891. procedure DoBeforeCancel; virtual;
  892. procedure DoBeforeClose; virtual;
  893. procedure DoBeforeDelete; virtual;
  894. procedure DoBeforeEdit; virtual;
  895. procedure DoBeforeInsert; virtual;
  896. procedure DoBeforeOpen; virtual;
  897. procedure DoBeforePost; virtual;
  898. procedure DoBeforeScroll; virtual;
  899. procedure DoBeforeRefresh; virtual;
  900. procedure DoOnCalcFields; virtual;
  901. procedure DoOnNewRecord; virtual;
  902. function FieldByNumber(FieldNo: Longint): TField;
  903. function FindRecord(Restart, GoForward: Boolean): Boolean; virtual;
  904. procedure FreeFieldBuffers; virtual;
  905. function GetBookmarkStr: TBookmarkStr; virtual;
  906. procedure GetCalcFields(Buffer: PChar); virtual;
  907. function GetCanModify: Boolean; virtual;
  908. procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  909. function GetFieldClass(FieldType: TFieldType): TFieldClass; virtual;
  910. Function GetfieldCount : Integer;
  911. function GetFieldValues(fieldname : string) : Variant; virtual;
  912. function GetIsIndexField(Field: TField): Boolean; virtual;
  913. function GetNextRecords: Longint; virtual;
  914. function GetNextRecord: Boolean; virtual;
  915. function GetPriorRecords: Longint; virtual;
  916. function GetPriorRecord: Boolean; virtual;
  917. function GetRecordCount: Longint; virtual;
  918. function GetRecNo: Longint; virtual;
  919. procedure InitFieldDefs; virtual;
  920. procedure InitRecord(Buffer: PChar); virtual;
  921. procedure InternalCancel; virtual;
  922. procedure InternalEdit; virtual;
  923. procedure InternalInsert; virtual;
  924. procedure InternalRefresh; virtual;
  925. procedure OpenCursor(InfoQuery: Boolean); virtual;
  926. procedure RefreshInternalCalcFields(Buffer: PChar); virtual;
  927. procedure RestoreState(const Value: TDataSetState);
  928. Procedure SetActive (Value : Boolean); virtual;
  929. procedure SetBookmarkStr(const Value: TBookmarkStr); virtual;
  930. procedure SetBufListSize(Value: Longint);
  931. procedure SetChildOrder(Component: TComponent; Order: Longint); override;
  932. procedure SetCurrentRecord(Index: Longint); virtual;
  933. procedure SetFiltered(Value: Boolean); virtual;
  934. procedure SetFilterOptions(Value: TFilterOptions); virtual;
  935. procedure SetFilterText(const Value: string); virtual;
  936. procedure SetFound(const Value: Boolean);
  937. procedure SetFieldValues(fieldname: string; Value: Variant); virtual;
  938. procedure SetModified(Value: Boolean);
  939. procedure SetName(const Value: TComponentName); override;
  940. procedure SetOnFilterRecord(const Value: TFilterRecordEvent); virtual;
  941. procedure SetRecNo(Value: Longint); virtual;
  942. procedure SetState(Value: TDataSetState);
  943. function SetTempState(const Value: TDataSetState): TDataSetState;
  944. Function Tempbuffer: PChar;
  945. procedure UpdateIndexDefs; virtual;
  946. property ActiveRecord: Longint read FActiveRecord;
  947. property CurrentRecord: Longint read FCurrentRecord;
  948. property BlobFieldCount: Longint read FBlobFieldCount;
  949. property BookmarkSize: Longint read FBookmarkSize write FBookmarkSize;
  950. property Buffers[Index: Longint]: PChar read GetBuffer;
  951. property BufferCount: Longint read FBufferCount;
  952. property CalcBuffer: PChar read FCalcBuffer;
  953. property CalcFieldsSize: Longint read FCalcFieldsSize;
  954. property InternalCalcFields: Boolean read FInternalCalcFields;
  955. property Constraints: TCheckConstraints read FConstraints write FConstraints;
  956. protected { abstract methods }
  957. function AllocRecordBuffer: PChar; virtual; abstract;
  958. procedure FreeRecordBuffer(var Buffer: PChar); virtual; abstract;
  959. procedure GetBookmarkData(Buffer: PChar; Data: Pointer); virtual; abstract;
  960. function GetBookmarkFlag(Buffer: PChar): TBookmarkFlag; virtual; abstract;
  961. function GetDataSource: TDataSource; virtual;
  962. function GetFieldData(Field: TField; Buffer: Pointer): Boolean; overload; virtual;
  963. function GetFieldData(Field: TField; Buffer: Pointer; NativeFormat: Boolean): Boolean; overload; virtual;
  964. function GetRecord(Buffer: PChar; GetMode: TGetMode; DoCheck: Boolean): TGetResult; virtual; abstract;
  965. function GetRecordSize: Word; virtual; abstract;
  966. procedure InternalAddRecord(Buffer: Pointer; AAppend: Boolean); virtual; abstract;
  967. procedure InternalClose; virtual; abstract;
  968. procedure InternalDelete; virtual; abstract;
  969. procedure InternalFirst; virtual; abstract;
  970. procedure InternalGotoBookmark(ABookmark: Pointer); virtual; abstract;
  971. procedure InternalHandleException; virtual;
  972. procedure InternalInitFieldDefs; virtual; abstract;
  973. procedure InternalInitRecord(Buffer: PChar); virtual; abstract;
  974. procedure InternalLast; virtual; abstract;
  975. procedure InternalOpen; virtual; abstract;
  976. procedure InternalPost; virtual; abstract;
  977. procedure InternalSetToRecord(Buffer: PChar); virtual; abstract;
  978. function IsCursorOpen: Boolean; virtual; abstract;
  979. procedure SetBookmarkFlag(Buffer: PChar; Value: TBookmarkFlag); virtual; abstract;
  980. procedure SetBookmarkData(Buffer: PChar; Data: Pointer); virtual; abstract;
  981. procedure SetFieldData(Field: TField; Buffer: Pointer); overload; virtual;
  982. procedure SetFieldData(Field: TField; Buffer: Pointer; NativeFormat: Boolean); overload; virtual;
  983. public
  984. constructor Create(AOwner: TComponent); override;
  985. destructor Destroy; override;
  986. function ActiveBuffer: PChar;
  987. procedure Append;
  988. procedure AppendRecord(const Values: array of const);
  989. function BookmarkValid(ABookmark: TBookmark): Boolean; virtual;
  990. procedure Cancel; virtual;
  991. procedure CheckBrowseMode;
  992. procedure ClearFields;
  993. procedure Close;
  994. function ControlsDisabled: Boolean;
  995. function CompareBookmarks(Bookmark1, Bookmark2: TBookmark): Longint; virtual;
  996. function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; virtual;
  997. procedure CursorPosChanged;
  998. procedure Delete;
  999. procedure DisableControls;
  1000. procedure Edit;
  1001. procedure EnableControls;
  1002. function FieldByName(const FieldName: string): TField;
  1003. function FindField(const FieldName: string): TField;
  1004. function FindFirst: Boolean;
  1005. function FindLast: Boolean;
  1006. function FindNext: Boolean;
  1007. function FindPrior: Boolean;
  1008. procedure First;
  1009. procedure FreeBookmark(ABookmark: TBookmark); virtual;
  1010. function GetBookmark: TBookmark; virtual;
  1011. function GetCurrentRecord(Buffer: PChar): Boolean; virtual;
  1012. procedure GetFieldList(List: TList; const FieldNames: string);
  1013. procedure GetFieldNames(List: TStrings);
  1014. procedure GotoBookmark(ABookmark: TBookmark);
  1015. procedure Insert;
  1016. procedure InsertRecord(const Values: array of const);
  1017. function IsEmpty: Boolean;
  1018. function IsLinkedTo(ADataSource: TDataSource): Boolean;
  1019. function IsSequenced: Boolean; virtual;
  1020. procedure Last;
  1021. function Locate(const keyfields: string; const keyvalues: Variant; options: TLocateOptions) : boolean; virtual;
  1022. function Lookup(const KeyFields: string; const KeyValues: Variant; const ResultFields: string): Variant; virtual;
  1023. function MoveBy(Distance: Longint): Longint;
  1024. procedure Next;
  1025. procedure Open;
  1026. procedure Post; virtual;
  1027. procedure Prior;
  1028. procedure Refresh;
  1029. procedure Resync(Mode: TResyncMode); virtual;
  1030. procedure SetFields(const Values: array of const);
  1031. function Translate(Src, Dest: PChar; ToOem: Boolean): Integer; virtual;
  1032. procedure UpdateCursorPos;
  1033. procedure UpdateRecord;
  1034. function UpdateStatus: TUpdateStatus; virtual;
  1035. property BOF: Boolean read FBOF;
  1036. property Bookmark: TBookmarkStr read GetBookmarkStr write SetBookmarkStr;
  1037. property CanModify: Boolean read GetCanModify;
  1038. property DataSource: TDataSource read GetDataSource;
  1039. property DefaultFields: Boolean read FDefaultFields;
  1040. property EOF: Boolean read FEOF;
  1041. property FieldCount: Longint read GetFieldCount;
  1042. property FieldDefs: TFieldDefs read FFieldDefs write FFieldDefs;
  1043. // property Fields[Index: Longint]: TField read GetField write SetField;
  1044. property Found: Boolean read FFound;
  1045. property Modified: Boolean read FModified write SetModified;
  1046. property IsUniDirectional: Boolean read FIsUniDirectional write FIsUniDirectional default False;
  1047. property RecordCount: Longint read GetRecordCount;
  1048. property RecNo: Longint read GetRecNo write SetRecNo;
  1049. property RecordSize: Word read GetRecordSize;
  1050. property State: TDataSetState read FState;
  1051. property Fields : TFields read FFieldList;
  1052. property FieldValues[fieldname : string] : Variant read GetFieldValues write SetFieldValues; default;
  1053. property Filter: string read FFilterText write SetFilterText;
  1054. property Filtered: Boolean read FFiltered write SetFiltered default False;
  1055. property FilterOptions: TFilterOptions read FFilterOptions write SetFilterOptions;
  1056. property Active: Boolean read GetActive write SetActive default False;
  1057. property AutoCalcFields: Boolean read FAutoCalcFields write FAutoCalcFields;
  1058. property BeforeOpen: TDataSetNotifyEvent read FBeforeOpen write FBeforeOpen;
  1059. property AfterOpen: TDataSetNotifyEvent read FAfterOpen write FAfterOpen;
  1060. property BeforeClose: TDataSetNotifyEvent read FBeforeClose write FBeforeClose;
  1061. property AfterClose: TDataSetNotifyEvent read FAfterClose write FAfterClose;
  1062. property BeforeInsert: TDataSetNotifyEvent read FBeforeInsert write FBeforeInsert;
  1063. property AfterInsert: TDataSetNotifyEvent read FAfterInsert write FAfterInsert;
  1064. property BeforeEdit: TDataSetNotifyEvent read FBeforeEdit write FBeforeEdit;
  1065. property AfterEdit: TDataSetNotifyEvent read FAfterEdit write FAfterEdit;
  1066. property BeforePost: TDataSetNotifyEvent read FBeforePost write FBeforePost;
  1067. property AfterPost: TDataSetNotifyEvent read FAfterPost write FAfterPost;
  1068. property BeforeCancel: TDataSetNotifyEvent read FBeforeCancel write FBeforeCancel;
  1069. property AfterCancel: TDataSetNotifyEvent read FAfterCancel write FAfterCancel;
  1070. property BeforeDelete: TDataSetNotifyEvent read FBeforeDelete write FBeforeDelete;
  1071. property AfterDelete: TDataSetNotifyEvent read FAfterDelete write FAfterDelete;
  1072. property BeforeScroll: TDataSetNotifyEvent read FBeforeScroll write FBeforeScroll;
  1073. property AfterScroll: TDataSetNotifyEvent read FAfterScroll write FAfterScroll;
  1074. property BeforeRefresh: TDataSetNotifyEvent read FBeforeRefresh write FBeforeRefresh;
  1075. property AfterRefresh: TDataSetNotifyEvent read FAfterRefresh write FAfterRefresh;
  1076. property OnCalcFields: TDataSetNotifyEvent read FOnCalcFields write FOnCalcFields;
  1077. property OnDeleteError: TDataSetErrorEvent read FOnDeleteError write FOnDeleteError;
  1078. property OnEditError: TDataSetErrorEvent read FOnEditError write FOnEditError;
  1079. property OnFilterRecord: TFilterRecordEvent read FOnFilterRecord write SetOnFilterRecord;
  1080. property OnNewRecord: TDataSetNotifyEvent read FOnNewRecord write FOnNewRecord;
  1081. property OnPostError: TDataSetErrorEvent read FOnPostError write FOnPostError;
  1082. end;
  1083. TDataLink = class(TPersistent)
  1084. private
  1085. FFIrstRecord,
  1086. FBufferCount : Integer;
  1087. FActive,
  1088. FDataSourceFixed,
  1089. FEditing,
  1090. FReadOnly,
  1091. FUpdatingRecord,
  1092. FVisualControl : Boolean;
  1093. FDataSource : TDataSource;
  1094. Function CalcFirstRecord(Index : Integer) : Integer;
  1095. Procedure CalcRange;
  1096. Procedure CheckActiveAndEditing;
  1097. Function GetDataset : TDataset;
  1098. procedure SetActive(AActive: Boolean);
  1099. procedure SetDataSource(Value: TDataSource);
  1100. Procedure SetReadOnly(Value : Boolean);
  1101. protected
  1102. procedure ActiveChanged; virtual;
  1103. procedure CheckBrowseMode; virtual;
  1104. procedure DataEvent(Event: TDataEvent; Info: Ptrint); virtual;
  1105. procedure DataSetChanged; virtual;
  1106. procedure DataSetScrolled(Distance: Integer); virtual;
  1107. procedure EditingChanged; virtual;
  1108. procedure FocusControl(Field: TFieldRef); virtual;
  1109. function GetActiveRecord: Integer; virtual;
  1110. function GetBOF: Boolean; virtual;
  1111. function GetBufferCount: Integer; virtual;
  1112. function GetEOF: Boolean; virtual;
  1113. function GetRecordCount: Integer; virtual;
  1114. procedure LayoutChanged; virtual;
  1115. function MoveBy(Distance: Integer): Integer; virtual;
  1116. procedure RecordChanged(Field: TField); virtual;
  1117. procedure SetActiveRecord(Value: Integer); virtual;
  1118. procedure SetBufferCount(Value: Integer); virtual;
  1119. procedure UpdateData; virtual;
  1120. property VisualControl: Boolean read FVisualControl write FVisualControl;
  1121. property FirstRecord: Integer read FFirstRecord write FFirstRecord;
  1122. public
  1123. constructor Create;
  1124. destructor Destroy; override;
  1125. function Edit: Boolean;
  1126. procedure UpdateRecord;
  1127. property Active: Boolean read FActive;
  1128. property ActiveRecord: Integer read GetActiveRecord write SetActiveRecord;
  1129. property BOF: Boolean read GetBOF;
  1130. property BufferCount: Integer read FBufferCount write SetBufferCount;
  1131. property DataSet: TDataSet read GetDataSet;
  1132. property DataSource: TDataSource read FDataSource write SetDataSource;
  1133. property DataSourceFixed: Boolean read FDataSourceFixed write FDataSourceFixed;
  1134. property Editing: Boolean read FEditing;
  1135. property Eof: Boolean read GetEOF;
  1136. property ReadOnly: Boolean read FReadOnly write SetReadOnly;
  1137. property RecordCount: Integer read GetRecordCount;
  1138. end;
  1139. { TDetailDataLink }
  1140. TDetailDataLink = class(TDataLink)
  1141. protected
  1142. function GetDetailDataSet: TDataSet; virtual;
  1143. public
  1144. property DetailDataSet: TDataSet read GetDetailDataSet;
  1145. end;
  1146. { TMasterDataLink }
  1147. TMasterDataLink = class(TDetailDataLink)
  1148. private
  1149. FDetailDataSet: TDataSet;
  1150. FFieldNames: string;
  1151. FFields: TList;
  1152. FOnMasterChange: TNotifyEvent;
  1153. FOnMasterDisable: TNotifyEvent;
  1154. procedure SetFieldNames(const Value: string);
  1155. protected
  1156. procedure ActiveChanged; override;
  1157. procedure CheckBrowseMode; override;
  1158. function GetDetailDataSet: TDataSet; override;
  1159. procedure LayoutChanged; override;
  1160. procedure RecordChanged(Field: TField); override;
  1161. Procedure DoMasterDisable; virtual;
  1162. Procedure DoMasterChange; virtual;
  1163. public
  1164. constructor Create(ADataSet: TDataSet);virtual;
  1165. destructor Destroy; override;
  1166. property FieldNames: string read FFieldNames write SetFieldNames;
  1167. property Fields: TList read FFields;
  1168. property OnMasterChange: TNotifyEvent read FOnMasterChange write FOnMasterChange;
  1169. property OnMasterDisable: TNotifyEvent read FOnMasterDisable write FOnMasterDisable;
  1170. end;
  1171. { TDataSource }
  1172. TDataChangeEvent = procedure(Sender: TObject; Field: TField) of object;
  1173. TDataSource = class(TComponent)
  1174. private
  1175. FDataSet: TDataSet;
  1176. FDataLinks: TList;
  1177. FEnabled: Boolean;
  1178. FAutoEdit: Boolean;
  1179. FState: TDataSetState;
  1180. FOnStateChange: TNotifyEvent;
  1181. FOnDataChange: TDataChangeEvent;
  1182. FOnUpdateData: TNotifyEvent;
  1183. procedure DistributeEvent(Event: TDataEvent; Info: Ptrint);
  1184. procedure RegisterDataLink(DataLink: TDataLink);
  1185. Procedure ProcessEvent(Event : TDataEvent; Info : Ptrint);
  1186. procedure SetDataSet(ADataSet: TDataSet);
  1187. procedure SetEnabled(Value: Boolean);
  1188. procedure UnregisterDataLink(DataLink: TDataLink);
  1189. protected
  1190. Procedure DoDataChange (Info : Pointer);virtual;
  1191. Procedure DoStateChange; virtual;
  1192. Procedure DoUpdateData;
  1193. property DataLinks: TList read FDataLinks;
  1194. public
  1195. constructor Create(AOwner: TComponent); override;
  1196. destructor Destroy; override;
  1197. procedure Edit;
  1198. function IsLinkedTo(ADataSet: TDataSet): Boolean;
  1199. property State: TDataSetState read FState;
  1200. published
  1201. property AutoEdit: Boolean read FAutoEdit write FAutoEdit default True;
  1202. property DataSet: TDataSet read FDataSet write SetDataSet;
  1203. property Enabled: Boolean read FEnabled write SetEnabled default True;
  1204. property OnStateChange: TNotifyEvent read FOnStateChange write FOnStateChange;
  1205. property OnDataChange: TDataChangeEvent read FOnDataChange write FOnDataChange;
  1206. property OnUpdateData: TNotifyEvent read FOnUpdateData write FOnUpdateData;
  1207. end;
  1208. { TDBDataset }
  1209. TDBDatasetClass = Class of TDBDataset;
  1210. TDBDataset = Class(TDataset)
  1211. Private
  1212. FDatabase : TDatabase;
  1213. FTransaction : TDBTransaction;
  1214. Protected
  1215. Procedure SetDatabase (Value : TDatabase); virtual;
  1216. Procedure SetTransaction(Value : TDBTransaction); virtual;
  1217. Procedure CheckDatabase;
  1218. Public
  1219. Destructor destroy; override;
  1220. Property DataBase : TDatabase Read FDatabase Write SetDatabase;
  1221. Property Transaction : TDBTransaction Read FTransaction Write SetTransaction;
  1222. end;
  1223. { TDBTransaction }
  1224. TDBTransactionClass = Class of TDBTransaction;
  1225. TDBTransaction = Class(TComponent)
  1226. Private
  1227. FActive : boolean;
  1228. FDatabase : TDatabase;
  1229. FDataSets : TList;
  1230. FOpenAfterRead : boolean;
  1231. Function GetDataSetCount : Longint;
  1232. Function GetDataset(Index : longint) : TDBDataset;
  1233. procedure RegisterDataset (DS : TDBDataset);
  1234. procedure UnRegisterDataset (DS : TDBDataset);
  1235. procedure RemoveDataSets;
  1236. procedure SetActive(Value : boolean);
  1237. Protected
  1238. Procedure SetDatabase (Value : TDatabase); virtual;
  1239. procedure CloseTrans;
  1240. procedure openTrans;
  1241. Procedure CheckDatabase;
  1242. Procedure CheckActive;
  1243. Procedure CheckInactive;
  1244. procedure EndTransaction; virtual; abstract;
  1245. procedure StartTransaction; virtual; abstract;
  1246. procedure InternalHandleException; virtual;
  1247. procedure Loaded; override;
  1248. Public
  1249. constructor Create(AOwner: TComponent); override;
  1250. Destructor destroy; override;
  1251. procedure CloseDataSets;
  1252. Property DataBase : TDatabase Read FDatabase Write SetDatabase;
  1253. published
  1254. property Active : boolean read FActive write setactive;
  1255. end;
  1256. { TDatabase }
  1257. TLoginEvent = procedure(Sender: TObject; Username, Password: string) of object;
  1258. TDatabaseClass = Class Of TDatabase;
  1259. TDatabase = class(TComponent)
  1260. private
  1261. FConnected : Boolean;
  1262. FDataBaseName : String;
  1263. FDataSets : TList;
  1264. FTransactions : TList;
  1265. FDirectory : String;
  1266. FKeepConnection : Boolean;
  1267. FLoginPrompt : Boolean;
  1268. FOnLogin : TLoginEvent;
  1269. FParams : TStrings;
  1270. FSQLBased : Boolean;
  1271. FOpenAfterRead : boolean;
  1272. Function GetDataSetCount : Longint;
  1273. Function GetTransactionCount : Longint;
  1274. Function GetDataset(Index : longint) : TDBDataset;
  1275. Function GetTransaction(Index : longint) : TDBTransaction;
  1276. procedure SetConnected (Value : boolean);
  1277. procedure RegisterDataset (DS : TDBDataset);
  1278. procedure RegisterTransaction (TA : TDBTransaction);
  1279. procedure UnRegisterDataset (DS : TDBDataset);
  1280. procedure UnRegisterTransaction(TA : TDBTransaction);
  1281. procedure RemoveDataSets;
  1282. procedure RemoveTransactions;
  1283. protected
  1284. Procedure CheckConnected;
  1285. Procedure CheckDisConnected;
  1286. procedure InternalHandleException; virtual;
  1287. procedure Loaded; override;
  1288. Procedure DoInternalConnect; Virtual;Abstract;
  1289. Procedure DoInternalDisConnect; Virtual;Abstract;
  1290. public
  1291. constructor Create(AOwner: TComponent); override;
  1292. destructor Destroy; override;
  1293. procedure Close;
  1294. procedure Open;
  1295. procedure CloseDataSets;
  1296. procedure CloseTransactions;
  1297. // procedure ApplyUpdates;
  1298. procedure StartTransaction; virtual; abstract;
  1299. procedure EndTransaction; virtual; abstract;
  1300. property DataSetCount: Longint read GetDataSetCount;
  1301. property DataSets[Index: Longint]: TDBDataSet read GetDataSet;
  1302. property TransactionCount: Longint read GetTransactionCount;
  1303. property Transactions[Index: Longint]: TDBTransaction read GetTransaction;
  1304. property Directory: string read FDirectory write FDirectory;
  1305. property IsSQLBased: Boolean read FSQLBased;
  1306. published
  1307. property Connected: Boolean read FConnected write SetConnected;
  1308. property DatabaseName: string read FDatabaseName write FDatabaseName;
  1309. property KeepConnection: Boolean read FKeepConnection write FKeepConnection;
  1310. property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt;
  1311. property Params : TStrings read FParams Write FParams;
  1312. property OnLogin: TLoginEvent read FOnLogin write FOnLogin;
  1313. end;
  1314. { TCustomConnection }
  1315. TCustomConnection = class(TDatabase)
  1316. private
  1317. FAfterConnect: TNotifyEvent;
  1318. FAfterDisconnect: TNotifyEvent;
  1319. FBeforeConnect: TNotifyEvent;
  1320. FBeforeDisconnect: TNotifyEvent;
  1321. procedure SetAfterConnect(const AValue: TNotifyEvent);
  1322. procedure SetAfterDisconnect(const AValue: TNotifyEvent);
  1323. procedure SetBeforeConnect(const AValue: TNotifyEvent);
  1324. procedure SetBeforeDisconnect(const AValue: TNotifyEvent);
  1325. protected
  1326. procedure DoInternalConnect; override;
  1327. procedure DoInternalDisconnect; override;
  1328. procedure DoConnect; virtual;
  1329. procedure DoDisconnect; virtual;
  1330. function GetConnected : boolean; virtual;
  1331. procedure StartTransaction; override;
  1332. procedure EndTransaction; override;
  1333. published
  1334. property AfterConnect : TNotifyEvent read FAfterConnect write SetAfterConnect;
  1335. property BeforeConnect : TNotifyEvent read FBeforeConnect write SetBeforeConnect;
  1336. property AfterDisconnect : TNotifyEvent read FAfterDisconnect write SetAfterDisconnect;
  1337. property BeforeDisconnect : TNotifyEvent read FBeforeDisconnect write SetBeforeDisconnect;
  1338. end;
  1339. { TBufDataset }
  1340. PBufRecLinkItem = ^TBufRecLinkItem;
  1341. TBufRecLinkItem = record
  1342. prior : PBufRecLinkItem;
  1343. next : PBufRecLinkItem;
  1344. end;
  1345. PBufBookmark = ^TBufBookmark;
  1346. TBufBookmark = record
  1347. BookmarkData : PBufRecLinkItem;
  1348. BookmarkFlag : TBookmarkFlag;
  1349. end;
  1350. PRecUpdateBuffer = ^TRecUpdateBuffer;
  1351. TRecUpdateBuffer = record
  1352. UpdateKind : TUpdateKind;
  1353. BookmarkData : pointer;
  1354. OldValuesBuffer : pchar;
  1355. end;
  1356. TRecordsUpdateBuffer = array of TRecUpdateBuffer;
  1357. TBufDataset = class(TDBDataSet)
  1358. private
  1359. FCurrentRecBuf : PBufRecLinkItem;
  1360. FLastRecBuf : PBufRecLinkItem;
  1361. FFirstRecBuf : PBufRecLinkItem;
  1362. FBRecordCount : integer;
  1363. FPacketRecords : integer;
  1364. FRecordSize : Integer;
  1365. FNullmaskSize : byte;
  1366. FOpen : Boolean;
  1367. FUpdateBuffer : TRecordsUpdateBuffer;
  1368. FCurrentUpdateBuffer : integer;
  1369. FFieldBufPositions : array of longint;
  1370. procedure CalcRecordSize;
  1371. function LoadBuffer(Buffer : PChar): TGetResult;
  1372. function GetFieldSize(FieldDef : TFieldDef) : longint;
  1373. function GetRecordUpdateBuffer : boolean;
  1374. procedure SetPacketRecords(aValue : integer);
  1375. function IntAllocRecordBuffer: PChar;
  1376. protected
  1377. procedure SetRecNo(Value: Longint); override;
  1378. function GetRecNo: Longint; override;
  1379. function AllocRecordBuffer: PChar; override;
  1380. procedure FreeRecordBuffer(var Buffer: PChar); override;
  1381. procedure InternalInitRecord(Buffer: PChar); override;
  1382. function GetCanModify: Boolean; override;
  1383. function GetRecord(Buffer: PChar; GetMode: TGetMode; DoCheck: Boolean): TGetResult; override;
  1384. procedure InternalOpen; override;
  1385. procedure InternalClose; override;
  1386. function getnextpacket : integer;
  1387. function GetRecordSize: Word; override;
  1388. procedure InternalPost; override;
  1389. procedure InternalDelete; override;
  1390. procedure InternalFirst; override;
  1391. procedure InternalLast; override;
  1392. procedure InternalSetToRecord(Buffer: PChar); override;
  1393. procedure InternalGotoBookmark(ABookmark: Pointer); override;
  1394. procedure SetBookmarkData(Buffer: PChar; Data: Pointer); override;
  1395. procedure SetBookmarkFlag(Buffer: PChar; Value: TBookmarkFlag); override;
  1396. procedure GetBookmarkData(Buffer: PChar; Data: Pointer); override;
  1397. function GetBookmarkFlag(Buffer: PChar): TBookmarkFlag; override;
  1398. function GetFieldData(Field: TField; Buffer: Pointer;
  1399. NativeFormat: Boolean): Boolean; override;
  1400. function GetFieldData(Field: TField; Buffer: Pointer): Boolean; override;
  1401. procedure SetFieldData(Field: TField; Buffer: Pointer;
  1402. NativeFormat: Boolean); override;
  1403. procedure SetFieldData(Field: TField; Buffer: Pointer); override;
  1404. function IsCursorOpen: Boolean; override;
  1405. function GetRecordCount: Longint; override;
  1406. function ApplyRecUpdate(UpdateKind : TUpdateKind) : boolean; virtual;
  1407. {abstracts, must be overidden by descendents}
  1408. function Fetch : boolean; virtual; abstract;
  1409. function LoadField(FieldDef : TFieldDef;buffer : pointer) : boolean; virtual; abstract;
  1410. public
  1411. constructor Create(AOwner: TComponent); override;
  1412. procedure ApplyUpdates; virtual;
  1413. procedure CancelUpdates; virtual;
  1414. destructor Destroy; override;
  1415. function Locate(const keyfields: string; const keyvalues: Variant; options: TLocateOptions) : boolean; override;
  1416. published
  1417. property PacketRecords : Integer read FPacketRecords write FPacketRecords default 10;
  1418. end;
  1419. { TParam }
  1420. TBlobData = string;
  1421. TParamBinding = array of integer;
  1422. TParamType = (ptUnknown, ptInput, ptOutput, ptInputOutput, ptResult);
  1423. TParamTypes = set of TParamType;
  1424. TParamStyle = (psInterbase,psPostgreSQL);
  1425. TParams = class;
  1426. TParam = class(TCollectionItem)
  1427. private
  1428. FNativeStr: string;
  1429. FValue: Variant;
  1430. FPrecision: Integer;
  1431. FNumericScale: Integer;
  1432. FName: string;
  1433. FDataType: TFieldType;
  1434. FBound: Boolean;
  1435. FParamType: TParamType;
  1436. FSize: Integer;
  1437. Function GetDataSet: TDataSet;
  1438. Function IsParamStored: Boolean;
  1439. protected
  1440. Procedure AssignParam(Param: TParam);
  1441. Procedure AssignTo(Dest: TPersistent); override;
  1442. Function GetAsBoolean: Boolean;
  1443. Function GetAsCurrency: Currency;
  1444. Function GetAsDateTime: TDateTime;
  1445. Function GetAsFloat: Double;
  1446. Function GetAsInteger: Longint;
  1447. Function GetAsLargeInt: LargeInt;
  1448. Function GetAsMemo: string;
  1449. Function GetAsString: string;
  1450. Function GetAsVariant: Variant;
  1451. Function GetDisplayName: string; override;
  1452. Function GetIsNull: Boolean;
  1453. Function IsEqual(AValue: TParam): Boolean;
  1454. Procedure SetAsBlob(const AValue: TBlobData);
  1455. Procedure SetAsBoolean(AValue: Boolean);
  1456. Procedure SetAsCurrency(const AValue: Currency);
  1457. Procedure SetAsDate(const AValue: TDateTime);
  1458. Procedure SetAsDateTime(const AValue: TDateTime);
  1459. Procedure SetAsFloat(const AValue: Double);
  1460. Procedure SetAsInteger(AValue: Longint);
  1461. Procedure SetAsLargeInt(AValue: LargeInt);
  1462. Procedure SetAsMemo(const AValue: string);
  1463. Procedure SetAsSmallInt(AValue: LongInt);
  1464. Procedure SetAsString(const AValue: string);
  1465. Procedure SetAsTime(const AValue: TDateTime);
  1466. Procedure SetAsVariant(const AValue: Variant);
  1467. Procedure SetAsWord(AValue: LongInt);
  1468. Procedure SetDataType(AValue: TFieldType);
  1469. Procedure SetText(const AValue: string);
  1470. public
  1471. constructor Create(ACollection: TCollection); overload; override;
  1472. constructor Create(AParams: TParams; AParamType: TParamType); reintroduce; overload;
  1473. Procedure Assign(Source: TPersistent); override;
  1474. Procedure AssignField(Field: TField);
  1475. Procedure AssignToField(Field: TField);
  1476. Procedure AssignFieldValue(Field: TField; const AValue: Variant);
  1477. procedure AssignFromField(Field : TField);
  1478. Procedure Clear;
  1479. Procedure GetData(Buffer: Pointer);
  1480. Function GetDataSize: Integer;
  1481. Procedure LoadFromFile(const FileName: string; BlobType: TBlobType);
  1482. Procedure LoadFromStream(Stream: TStream; BlobType: TBlobType);
  1483. Procedure SetBlobData(Buffer: Pointer; ASize: Integer);
  1484. Procedure SetData(Buffer: Pointer);
  1485. Property AsBlob : TBlobData read GetAsString write SetAsBlob;
  1486. Property AsBoolean : Boolean read GetAsBoolean write SetAsBoolean;
  1487. Property AsCurrency : Currency read GetAsCurrency write SetAsCurrency;
  1488. Property AsDate : TDateTime read GetAsDateTime write SetAsDate;
  1489. Property AsDateTime : TDateTime read GetAsDateTime write SetAsDateTime;
  1490. Property AsFloat : Double read GetAsFloat write SetAsFloat;
  1491. Property AsInteger : LongInt read GetAsInteger write SetAsInteger;
  1492. Property AsLargeInt : LargeInt read GetAsLargeInt write SetAsLargeInt;
  1493. Property AsMemo : string read GetAsMemo write SetAsMemo;
  1494. Property AsSmallInt : LongInt read GetAsInteger write SetAsSmallInt;
  1495. Property AsString : string read GetAsString write SetAsString;
  1496. Property AsTime : TDateTime read GetAsDateTime write SetAsTime;
  1497. Property AsWord : LongInt read GetAsInteger write SetAsWord;
  1498. Property Bound : Boolean read FBound write FBound;
  1499. Property Dataset : TDataset Read GetDataset;
  1500. Property IsNull : Boolean read GetIsNull;
  1501. Property NativeStr : string read FNativeStr write FNativeStr;
  1502. Property Text : string read GetAsString write SetText;
  1503. Property Value : Variant read GetAsVariant write SetAsVariant stored IsParamStored;
  1504. published
  1505. Property DataType : TFieldType read FDataType write SetDataType;
  1506. Property Name : string read FName write FName;
  1507. Property NumericScale : Integer read FNumericScale write FNumericScale default 0;
  1508. Property ParamType : TParamType read FParamType write FParamType;
  1509. Property Precision : Integer read FPrecision write FPrecision default 0;
  1510. Property Size : Integer read FSize write FSize default 0;
  1511. end;
  1512. { TParams }
  1513. TParams = class(TCollection)
  1514. private
  1515. FOwner: TPersistent;
  1516. Function GetItem(Index: Integer): TParam;
  1517. Function GetParamValue(const ParamName: string): Variant;
  1518. Procedure SetItem(Index: Integer; Value: TParam);
  1519. Procedure SetParamValue(const ParamName: string; const Value: Variant);
  1520. protected
  1521. Procedure AssignTo(Dest: TPersistent); override;
  1522. Function GetDataSet: TDataSet;
  1523. Function GetOwner: TPersistent; override;
  1524. public
  1525. Constructor Create(AOwner: TPersistent); overload;
  1526. Constructor Create; overload;
  1527. Procedure AddParam(Value: TParam);
  1528. Procedure AssignValues(Value: TParams);
  1529. Function CreateParam(FldType: TFieldType; const ParamName: string; ParamType: TParamType): TParam;
  1530. Function FindParam(const Value: string): TParam;
  1531. Procedure GetParamList(List: TList; const ParamNames: string);
  1532. Function IsEqual(Value: TParams): Boolean;
  1533. Function ParamByName(const Value: string): TParam;
  1534. Function ParseSQL(SQL: String; DoCreate: Boolean): String;
  1535. Function ParseSQL(SQL: String; DoCreate: Boolean; ParameterStyle : TParamStyle): String; overload;
  1536. Function ParseSQL(SQL: String; DoCreate: Boolean; ParameterStyle : TParamStyle; var ParamBinding: TParambinding): String; overload;
  1537. Procedure RemoveParam(Value: TParam);
  1538. Procedure CopyParamValuesFromDataset(ADataset : TDataset; CopyBound : Boolean);
  1539. Property Dataset : TDataset Read GetDataset;
  1540. Property Items[Index: Integer] : TParam read GetItem write SetItem; default;
  1541. Property ParamValues[const ParamName: string] : Variant read GetParamValue write SetParamValue;
  1542. end;
  1543. TMasterParamsDataLink = Class(TMasterDataLink)
  1544. Private
  1545. FParams : TParams;
  1546. Procedure SetParams(AVAlue : TParams);
  1547. Protected
  1548. Procedure DoMasterDisable; override;
  1549. Procedure DoMasterChange; override;
  1550. Public
  1551. constructor Create(ADataSet: TDataSet); override;
  1552. Procedure RefreshParamNames; virtual;
  1553. Procedure CopyParamsFromMaster(CopyBound : Boolean); virtual;
  1554. Property Params : TParams Read FParams Write SetParams;
  1555. end;
  1556. const
  1557. FieldTypetoVariantMap : array[TFieldType] of Integer = (varError, varOleStr, varSmallint,
  1558. varInteger, varSmallint, varBoolean, varDouble, varCurrency, varCurrency,
  1559. varDate, varDate, varDate, varOleStr, varOleStr, varInteger, varOleStr,
  1560. varOleStr, varOleStr, varOleStr, varOleStr, varOleStr, varOleStr, varError,
  1561. varOleStr, varOleStr, varError, varError, varError, varError, varError,
  1562. varOleStr, varOleStr, varVariant, varUnknown, varDispatch, varOleStr, varOleStr,varOleStr);
  1563. Const
  1564. Fieldtypenames : Array [TFieldType] of String[15] =
  1565. (
  1566. 'Unknown',
  1567. 'String',
  1568. 'Smallint',
  1569. 'Integer',
  1570. 'Word',
  1571. 'Boolean',
  1572. 'Float',
  1573. 'Currency',
  1574. 'BCD',
  1575. 'Date',
  1576. 'Time',
  1577. 'DateTime',
  1578. 'Bytes',
  1579. 'VarBytes',
  1580. 'AutoInc',
  1581. 'Blob',
  1582. 'Memo',
  1583. 'Graphic',
  1584. 'FmtMemo',
  1585. 'ParadoxOle',
  1586. 'DBaseOle',
  1587. 'TypedBinary',
  1588. 'Cursor',
  1589. 'FixedChar',
  1590. 'WideString',
  1591. 'Largeint',
  1592. 'ADT',
  1593. 'Array',
  1594. 'Reference',
  1595. 'DataSet',
  1596. 'OraBlob',
  1597. 'OraClob',
  1598. 'Variant',
  1599. 'Interface',
  1600. 'IDispatch',
  1601. 'Guid',
  1602. 'TimeStamp',
  1603. 'FMTBcd'
  1604. );
  1605. { 'Unknown',
  1606. 'String',
  1607. 'Smallint',
  1608. 'Integer',
  1609. 'Word',
  1610. 'Boolean',
  1611. 'Float',
  1612. 'Date',
  1613. 'Time',
  1614. 'DateTime',
  1615. 'Bytes',
  1616. 'VarBytes',
  1617. 'AutoInc',
  1618. 'Blob',
  1619. 'Memo',
  1620. 'Graphic',
  1621. 'FmtMemo',
  1622. 'ParadoxOle',
  1623. 'DBaseOle',
  1624. 'TypedBinary',
  1625. 'Cursor'
  1626. );}
  1627. const
  1628. DefaultFieldClasses : Array [TFieldType] of TFieldClass =
  1629. ( { ftUnknown} Tfield,
  1630. { ftString} TStringField,
  1631. { ftSmallint} TSmallIntField,
  1632. { ftInteger} TLongintField,
  1633. { ftWord} TLongintField,
  1634. { ftBoolean} TBooleanField,
  1635. { ftFloat} TFloatField,
  1636. { ftCurrency} Nil,
  1637. { ftBCD} TBCDField,
  1638. { ftDate} TDateField,
  1639. { ftTime} TTimeField,
  1640. { ftDateTime} TDateTimeField,
  1641. { ftBytes} TBytesField,
  1642. { ftVarBytes} TVarBytesField,
  1643. { ftAutoInc} TAutoIncField,
  1644. { ftBlob} TBlobField,
  1645. { ftMemo} TMemoField,
  1646. { ftGraphic} TGraphicField,
  1647. { ftFmtMemo} TMemoField,
  1648. { ftParadoxOle} Nil,
  1649. { ftDBaseOle} Nil,
  1650. { ftTypedBinary} Nil,
  1651. { ftCursor} Nil,
  1652. { ftFixedChar} TStringField,
  1653. { ftWideString} Nil,
  1654. { ftLargeint} TLargeIntField,
  1655. { ftADT} Nil,
  1656. { ftArray} Nil,
  1657. { ftReference} Nil,
  1658. { ftDataSet} Nil,
  1659. { ftOraBlob} TBlobField,
  1660. { ftOraClob} TMemoField,
  1661. { ftVariant} Nil,
  1662. { ftInterface} Nil,
  1663. { ftIDispatch} Nil,
  1664. { ftGuid} Nil,
  1665. { ftTimeStamp} Nil,
  1666. { ftFMTBcd} Nil
  1667. );
  1668. dsEditModes = [dsEdit, dsInsert, dsSetKey];
  1669. dsWriteModes = [dsEdit, dsInsert, dsSetKey, dsCalcFields, dsFilter,
  1670. dsNewValue, dsInternalCalc];
  1671. { Auxiliary functions }
  1672. Procedure DatabaseError (Const Msg : String);
  1673. Procedure DatabaseError (Const Msg : String; Comp : TComponent);
  1674. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of Const);
  1675. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of const;
  1676. Comp : TComponent);
  1677. Function ExtractFieldName(Const Fields: String; var Pos: Integer): String;
  1678. Function DateTimeRecToDateTime(DT: TFieldType; Data: TDateTimeRec): TDateTime;
  1679. Function DateTimeToDateTimeRec(DT: TFieldType; Data: TDateTime): TDateTimeRec;
  1680. implementation
  1681. uses dbconst,typinfo;
  1682. { ---------------------------------------------------------------------
  1683. Auxiliary functions
  1684. ---------------------------------------------------------------------}
  1685. Procedure DatabaseError (Const Msg : String);
  1686. begin
  1687. Raise EDataBaseError.Create(Msg);
  1688. end;
  1689. Procedure DatabaseError (Const Msg : String; Comp : TComponent);
  1690. begin
  1691. Raise EDatabaseError.CreateFmt('%s : %s',[Comp.Name,Msg]);
  1692. end;
  1693. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of Const);
  1694. begin
  1695. Raise EDatabaseError.CreateFmt(Fmt,Args);
  1696. end;
  1697. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of const;
  1698. Comp : TComponent);
  1699. begin
  1700. Raise EDatabaseError.CreateFmt(Format('%s : %s',[Comp.Name,Fmt]),Args);
  1701. end;
  1702. Function ExtractFieldName(Const Fields: String; var Pos: Integer): String;
  1703. var
  1704. i: integer;
  1705. begin
  1706. for i := Pos to Length(Fields) do begin
  1707. if Fields[i] = ';' then begin
  1708. Result := Copy(Fields, Pos, i - Pos);
  1709. Pos := i + 1;
  1710. Exit;
  1711. end;
  1712. end;
  1713. Result := Copy(Fields, Pos, Length(Fields));
  1714. Pos := Length(Fields) + 1;
  1715. end;
  1716. { TIndexDef }
  1717. constructor TIndexDef.Create(Owner: TIndexDefs; const AName, TheFields: string;
  1718. TheOptions: TIndexOptions);
  1719. begin
  1720. inherited create(Owner);
  1721. FName := aname;
  1722. FFields := TheFields;
  1723. FOptions := TheOptions;
  1724. end;
  1725. destructor TIndexDef.Destroy;
  1726. begin
  1727. inherited Destroy;
  1728. end;
  1729. { TIndexDefs }
  1730. Function TIndexDefs.GetItem (Index : integer) : TIndexDef;
  1731. begin
  1732. Result:=(Inherited GetItem(Index)) as TIndexDef;
  1733. end;
  1734. Procedure TIndexDefs.SetItem(Index: Integer; Value: TIndexDef);
  1735. begin
  1736. Inherited SetItem(Index,Value);
  1737. end;
  1738. constructor TIndexDefs.Create(DataSet: TDataSet);
  1739. begin
  1740. FDataset := Dataset;
  1741. inherited create(Dataset, TIndexDef);
  1742. end;
  1743. destructor TIndexDefs.Destroy;
  1744. begin
  1745. inherited Destroy;
  1746. end;
  1747. Function TIndexDefs.AddIndexDef: TIndexDef;
  1748. begin
  1749. // Result := inherited add as TIndexDef;
  1750. Result:=TIndexDef.Create(Self,'','',[]);
  1751. end;
  1752. procedure TIndexDefs.Add(const Name, Fields: string; Options: TIndexOptions);
  1753. begin
  1754. TIndexDef.Create(Self,Name,Fields,Options);
  1755. end;
  1756. procedure TIndexDefs.Assign(IndexDefs: TIndexDefs);
  1757. begin
  1758. //!! To be implemented
  1759. end;
  1760. {procedure TIndexDefs.Clear;
  1761. begin
  1762. //!! To be implemented
  1763. end;}
  1764. function TIndexDefs.Find(const IndexName: string): TIndexDef;
  1765. var i: integer;
  1766. begin
  1767. Result := Nil;
  1768. for i := 0 to Count - 1 do
  1769. if AnsiSameText(Items[i].Name, IndexName) then begin
  1770. Result := Items[i];
  1771. Break;
  1772. end;
  1773. if (Result=Nil) Then
  1774. DatabaseErrorFmt(SIndexNotFound, [IndexName], FDataSet);
  1775. end;
  1776. function TIndexDefs.FindIndexForFields(const Fields: string): TIndexDef;
  1777. begin
  1778. //!! To be implemented
  1779. end;
  1780. function TIndexDefs.GetIndexForFields(const Fields: string;
  1781. CaseInsensitive: Boolean): TIndexDef;
  1782. var
  1783. i, FieldsLen: integer;
  1784. Last: TIndexDef;
  1785. begin
  1786. Last := nil;
  1787. FieldsLen := Length(Fields);
  1788. for i := 0 to Count - 1 do
  1789. begin
  1790. Result := Items[I];
  1791. if (Result.Options * [ixDescending, ixExpression] = []) and
  1792. (not CaseInsensitive or (ixCaseInsensitive in Result.Options)) and
  1793. AnsiSameText(Fields, Result.Fields) then
  1794. begin
  1795. Exit;
  1796. end else
  1797. if AnsiSameText(Fields, Copy(Result.Fields, 1, FieldsLen)) and
  1798. ((Length(Result.Fields) = FieldsLen) or
  1799. (Result.Fields[FieldsLen + 1] = ';')) then
  1800. begin
  1801. if (Last = nil) or
  1802. ((Last <> nil) And (Length(Last.Fields) > Length(Result.Fields))) then
  1803. Last := Result;
  1804. end;
  1805. end;
  1806. Result := Last;
  1807. end;
  1808. function TIndexDefs.IndexOf(const Name: string): Longint;
  1809. var i: LongInt;
  1810. begin
  1811. Result := -1;
  1812. for i := 0 to Count - 1 do
  1813. if AnsiSameText(Items[i].Name, Name) then
  1814. begin
  1815. Result := i;
  1816. Break;
  1817. end;
  1818. end;
  1819. procedure TIndexDefs.Update;
  1820. begin
  1821. if assigned(Fdataset) then
  1822. Fdataset.UpdateIndexDefs;
  1823. end;
  1824. { TCheckConstraint }
  1825. procedure TCheckConstraint.Assign(Source: TPersistent);
  1826. begin
  1827. //!! To be implemented
  1828. end;
  1829. { TCheckConstraints }
  1830. Function TCheckConstraints.GetItem(Index : Longint) : TCheckConstraint;
  1831. begin
  1832. //!! To be implemented
  1833. end;
  1834. Procedure TCheckConstraints.SetItem(index : Longint; Value : TCheckConstraint);
  1835. begin
  1836. //!! To be implemented
  1837. end;
  1838. function TCheckConstraints.GetOwner: TPersistent;
  1839. begin
  1840. //!! To be implemented
  1841. end;
  1842. constructor TCheckConstraints.Create(AOwner: TPersistent);
  1843. begin
  1844. //!! To be implemented
  1845. end;
  1846. function TCheckConstraints.Add: TCheckConstraint;
  1847. begin
  1848. //!! To be implemented
  1849. end;
  1850. { TLookupList }
  1851. constructor TLookupList.Create;
  1852. begin
  1853. FList := TList.Create;
  1854. end;
  1855. destructor TLookupList.Destroy;
  1856. begin
  1857. if FList <> nil then Clear;
  1858. FList.Free;
  1859. inherited Destroy;
  1860. end;
  1861. procedure TLookupList.Add(const AKey, AValue: Variant);
  1862. var LookupRec: PLookupListRec;
  1863. begin
  1864. New(LookupRec);
  1865. LookupRec^.Key := AKey;
  1866. LookupRec^.Value := AValue;
  1867. FList.Add(LookupRec);
  1868. end;
  1869. procedure TLookupList.Clear;
  1870. var i: integer;
  1871. begin
  1872. for i := 0 to FList.Count - 1 do Dispose(PLookupListRec(FList[i]));
  1873. FList.Clear;
  1874. end;
  1875. function TLookupList.ValueOfKey(const AKey: Variant): Variant;
  1876. var I: Integer;
  1877. begin
  1878. Result := Null;
  1879. if VarIsNull(AKey) then Exit;
  1880. i := FList.Count - 1;
  1881. while (i > 0) And (PLookupListRec(FList.Items[I])^.Key <> AKey) do Dec(i);
  1882. if i >= 0 then Result := PLookupListRec(FList.Items[I])^.Value;
  1883. end;
  1884. {$i dataset.inc}
  1885. {$i fields.inc}
  1886. {$i datasource.inc}
  1887. {$i database.inc}
  1888. {$i BufDataset.inc}
  1889. {$i dsparams.inc}
  1890. end.