db.pp 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
  5. Free Pascal development team
  6. DB header file with interface section.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit db;
  14. {$mode objfpc}
  15. {$h+}
  16. interface
  17. uses Classes,Sysutils;
  18. const
  19. dsMaxBufferCount = MAXINT div 8;
  20. dsMaxStringSize = 8192;
  21. // Used in AsBoolean for string fields to determine
  22. // whether it's true or false.
  23. YesNoChars : Array[Boolean] of char = ('Y','N');
  24. type
  25. { Auxiliary type }
  26. TStringFieldBuffer = Array[0..dsMaxStringSize] of Char;
  27. { Misc Dataset types }
  28. TDataSetState = (dsInactive, dsBrowse, dsEdit, dsInsert, dsSetKey,
  29. dsCalcFields, dsFilter, dsNewValue, dsOldValue, dsCurValue);
  30. TDataEvent = (deFieldChange, deRecordChange, deDataSetChange,
  31. deDataSetScroll, deLayoutChange, deUpdateRecord, deUpdateState,
  32. deCheckBrowseMode, dePropertyChange, deFieldListChange, deFocusControl);
  33. TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);
  34. { Forward declarations }
  35. TFieldDef = class;
  36. TFieldDefs = class;
  37. TField = class;
  38. TFields = Class;
  39. TDataSet = class;
  40. TDataBase = Class;
  41. { Exception classes }
  42. EDatabaseError = class(Exception);
  43. { TFieldDef }
  44. TFieldClass = class of TField;
  45. TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
  46. ftBoolean, ftFloat, ftDate, ftTime, ftDateTime,
  47. ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
  48. ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor);
  49. TFieldDef = class(TComponent)
  50. Private
  51. FDataType : TFieldType;
  52. FFieldNo : Longint;
  53. FInternalCalcField : Boolean;
  54. FPrecision : Longint;
  55. FRequired : Boolean;
  56. FSize : Word;
  57. FName : String;
  58. Function GetFieldClass : TFieldClass;
  59. public
  60. constructor Create(AOwner: TFieldDefs; const AName: string;
  61. ADataType: TFieldType; ASize: Word; ARequired: Boolean; AFieldNo: Longint);
  62. destructor Destroy; override;
  63. function CreateField(AOwner: TComponent): TField;
  64. property InternalCalcField: Boolean read FInternalCalcField write FInternalCalcField;
  65. property DataType: TFieldType read FDataType;
  66. property FieldClass: TFieldClass read GetFieldClass;
  67. property FieldNo: Longint read FFieldNo;
  68. property Name: string read FName;
  69. property Precision: Longint read FPrecision write FPrecision;
  70. property Required: Boolean read FRequired;
  71. property Size: Word read FSize;
  72. end;
  73. { TFieldDefs }
  74. TFieldDefs = class(TComponent)
  75. private
  76. FDataSet: TDataSet;
  77. FItems: TList;
  78. FUpdated: Boolean;
  79. function GetCount: Longint;
  80. function GetItem(Index: Longint): TFieldDef;
  81. public
  82. constructor Create(ADataSet: TDataSet);
  83. destructor Destroy; override;
  84. procedure Add(const AName: string; ADataType: TFieldType; ASize: Word;
  85. ARequired: Boolean);
  86. procedure Assign(FieldDefs: TFieldDefs);
  87. procedure Clear;
  88. function Find(const AName: string): TFieldDef;
  89. function IndexOf(const AName: string): Longint;
  90. procedure Update;
  91. property Count: Longint read GetCount;
  92. property Items[Index: Longint]: TFieldDef read GetItem; default;
  93. end;
  94. { TField }
  95. TFieldKind = (fkData, fkCalculated, fkLookup, fkInternalCalc);
  96. TFieldKinds = Set of TFieldKind;
  97. TFieldNotifyEvent = procedure(Sender: TField) of object;
  98. TFieldGetTextEvent = procedure(Sender: TField; var Text: string;
  99. DisplayText: Boolean) of object;
  100. TFieldSetTextEvent = procedure(Sender: TField; const Text: string) of object;
  101. TFieldRef = ^TField;
  102. TFieldChars = set of Char;
  103. { TAlignment may need to come from somewhere else }
  104. TAlignMent = (taLeftjustify,taCenter,taRightJustify);
  105. TField = class(TComponent)
  106. Private
  107. FAlignMent : TAlignment;
  108. FAttributeSet : String;
  109. FBuffers : ppchar;
  110. FCalculated : Boolean;
  111. FCanModify : Boolean;
  112. FConstraintErrorMessage : String;
  113. FCustomConstraint : String;
  114. FDataSet : TDataSet;
  115. FDataSize : Word;
  116. FDataType : TFieldType;
  117. FDefaultExpression : String;
  118. FDisplayLabel : String;
  119. FDisplayWidth : Longint;
  120. FEditText : String;
  121. FFieldKind : TFieldKind;
  122. FFieldName : String;
  123. FFieldNo : Longint;
  124. FFields : TFields;
  125. FHasConstraints : Boolean;
  126. FImportedConstraint : String;
  127. FIsIndexField : Boolean;
  128. FKeyFields : String;
  129. FLookupCache : Boolean;
  130. FLookupDataSet : TDataSet;
  131. FLookupKeyfields : String;
  132. FLookupresultField : String;
  133. FOffset : Word;
  134. FOnChange : TFieldNotifyEvent;
  135. FOnGetText: TFieldGetTextEvent;
  136. FOnSetText: TFieldSetTextEvent;
  137. FOnValidate: TFieldNotifyEvent;
  138. FOrigin : String;
  139. FReadOnly : Boolean;
  140. FRequired : Boolean;
  141. FSize : Word;
  142. FValidChars : TFieldChars;
  143. FValueBuffer : Pointer;
  144. FValidating : Boolean;
  145. FVisible : Boolean;
  146. Function GetIndex : longint;
  147. Procedure SetDataset(VAlue : TDataset);
  148. protected
  149. function AccessError(const TypeName: string): EDatabaseError;
  150. procedure CheckInactive;
  151. class procedure CheckTypeSize(AValue: Longint); virtual;
  152. procedure Change; virtual;
  153. procedure DataChanged;
  154. procedure FreeBuffers; virtual;
  155. function GetAsBoolean: Boolean; virtual;
  156. function GetAsDateTime: TDateTime; virtual;
  157. function GetAsFloat: Extended; virtual;
  158. function GetAsLongint: Longint; virtual;
  159. function GetAsString: string; virtual;
  160. function GetCanModify: Boolean; virtual;
  161. function GetDataSize: Word; virtual;
  162. function GetDefaultWidth: Longint; virtual;
  163. function GetDisplayName : String;
  164. function GetIsNull: Boolean; virtual;
  165. function GetParentComponent: TComponent; override;
  166. procedure GetText(var AText: string; ADisplayText: Boolean); virtual;
  167. function HasParent: Boolean; override;
  168. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  169. procedure PropertyChanged(LayoutAffected: Boolean);
  170. procedure ReadState(Reader: TReader); override;
  171. procedure SetAsBoolean(AValue: Boolean); virtual;
  172. procedure SetAsDateTime(AValue: TDateTime); virtual;
  173. procedure SetAsFloat(AValue: Extended); virtual;
  174. procedure SetAsLongint(AValue: Longint); virtual;
  175. procedure SetAsString(const AValue: string); virtual;
  176. procedure SetDataType(AValue: TFieldType);
  177. procedure SetSize(AValue: Word); virtual;
  178. procedure SetParentComponent(AParent: TComponent); override;
  179. procedure SetText(const AValue: string); virtual;
  180. public
  181. constructor Create(AOwner: TComponent); override;
  182. destructor Destroy; override;
  183. procedure Assign(Source: TPersistent); override;
  184. procedure Clear; virtual;
  185. procedure FocusControl;
  186. function GetData(Buffer: Pointer): Boolean;
  187. class function IsBlob: Boolean; virtual;
  188. function IsValidChar(InputChar: Char): Boolean; virtual;
  189. procedure SetData(Buffer: Pointer);
  190. procedure SetFieldType(AValue: TFieldType); virtual;
  191. procedure Validate(Buffer: Pointer);
  192. property AsBoolean: Boolean read GetAsBoolean write SetAsBoolean;
  193. property AsDateTime: TDateTime read GetAsDateTime write SetAsDateTime;
  194. property AsFloat: Extended read GetAsFloat write SetAsFloat;
  195. property AsLongint: Longint read GetAsLongint write SetAsLongint;
  196. property AsString: string read GetAsString write SetAsString;
  197. property AttributeSet: string read FAttributeSet write FAttributeSet;
  198. property Calculated: Boolean read FCalculated write FCalculated;
  199. property CanModify: Boolean read FCanModify;
  200. property DataSet: TDataSet read FDataSet write SetDataSet;
  201. property DataSize: Word read GetDataSize;
  202. property DataType: TFieldType read FDataType;
  203. property FieldNo: Longint read FFieldNo;
  204. property IsIndexField: Boolean read FIsIndexField;
  205. property IsNull: Boolean read GetIsNull;
  206. property Offset: word read FOffset;
  207. property Size: Word read FSize write FSize;
  208. property Text: string read FEditText write FEditText;
  209. property ValidChars : TFieldChars Read FValidChars;
  210. published
  211. property AlignMent : TAlignMent Read FAlignMent write FAlignment;
  212. property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
  213. property ConstraintErrorMessage: string read FConstraintErrorMessage write FConstraintErrorMessage;
  214. property DefaultExpression: string read FDefaultExpression write FDefaultExpression;
  215. property DisplayLabel : string read FDisplayLabel write FDisplayLabel;
  216. property DisplayName : String Read GetDisplayName;
  217. property DisplayWidth: Longint read FDisplayWidth write FDisplayWidth;
  218. property FieldKind: TFieldKind read FFieldKind write FFieldKind;
  219. property FieldName: string read FFieldName write FFieldName;
  220. property HasConstraints: Boolean read FHasConstraints;
  221. property Index: Longint read GetIndex;
  222. property ImportedConstraint: string read FImportedConstraint write FImportedConstraint;
  223. property LookupDataSet: TDataSet read FLookupDataSet write FLookupDataSet;
  224. property LookupKeyFields: string read FLookupKeyFields write FLookupKeyFields;
  225. property LookupResultField: string read FLookupResultField write FLookupResultField;
  226. property KeyFields: string read FKeyFields write FKeyFields;
  227. property LookupCache: Boolean read FLookupCache write FLookupCache;
  228. property Origin: string read FOrigin write FOrigin;
  229. property ReadOnly: Boolean read FReadOnly write FReadOnly;
  230. property Required: Boolean read FRequired write FRequired;
  231. property Visible: Boolean read FVisible write FVisible;
  232. property OnChange: TFieldNotifyEvent read FOnChange write FOnChange;
  233. property OnGetText: TFieldGetTextEvent read FOnGetText write FOnGetText;
  234. property OnSetText: TFieldSetTextEvent read FOnSetText write FOnSetText;
  235. property OnValidate: TFieldNotifyEvent read FOnValidate write FOnValidate;
  236. end;
  237. { TStringField }
  238. TStringField = class(TField)
  239. protected
  240. class procedure CheckTypeSize(AValue: Longint); override;
  241. function GetAsBoolean: Boolean; override;
  242. function GetAsDateTime: TDateTime; override;
  243. function GetAsFloat: Extended; override;
  244. function GetAsLongint: Longint; override;
  245. function GetAsString: string; override;
  246. function GetDataSize: Word; override;
  247. function GetDefaultWidth: Longint; override;
  248. procedure GetText(var AText: string; DisplayText: Boolean); override;
  249. function GetValue(var AValue: string): Boolean;
  250. procedure SetAsBoolean(AValue: Boolean); override;
  251. procedure SetAsDateTime(AValue: TDateTime); override;
  252. procedure SetAsFloat(AValue: Extended); override;
  253. procedure SetAsLongint(AValue: Longint); override;
  254. procedure SetAsString(const AValue: string); override;
  255. public
  256. constructor Create(AOwner: TComponent); override;
  257. property Value: string read GetAsString write SetAsString;
  258. published
  259. property Size default 20;
  260. end;
  261. { TNumericField }
  262. TNumericField = class(TField)
  263. Private
  264. FDisplayFormat : String;
  265. FEditFormat : String;
  266. protected
  267. procedure RangeError(AValue, Min, Max: Extended);
  268. procedure SetDisplayFormat(const AValue: string);
  269. procedure SetEditFormat(const AValue: string);
  270. public
  271. constructor Create(AOwner: TComponent); override;
  272. published
  273. property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
  274. property EditFormat: string read FEditFormat write SetEditFormat;
  275. end;
  276. { TLongintField }
  277. TLongintField = class(TNumericField)
  278. private
  279. FMinValue,
  280. FMaxValue,
  281. FMinRange,
  282. FMAxRange : Longint;
  283. Procedure SetMinValue (AValue : longint);
  284. Procedure SetMaxValue (AValue : longint);
  285. protected
  286. function GetAsFloat: Extended; override;
  287. function GetAsLongint: Longint; override;
  288. function GetAsString: string; override;
  289. function GetDataSize: Word; override;
  290. procedure GetText(var AText: string; DisplayText: Boolean); override;
  291. function GetValue(var AValue: Longint): Boolean;
  292. procedure SetAsFloat(AValue: Extended); override;
  293. procedure SetAsLongint(AValue: Longint); override;
  294. procedure SetAsString(const AValue: string); override;
  295. public
  296. constructor Create(AOwner: TComponent); override;
  297. Function CheckRange(AValue : longint) : Boolean;
  298. property Value: Longint read GetAsLongint write SetAsLongint;
  299. published
  300. property MaxValue: Longint read FMaxValue write SetMaxValue default 0;
  301. property MinValue: Longint read FMinValue write SetMinValue default 0;
  302. end;
  303. TIntegerField = TLongintField;
  304. { TSmallintField }
  305. TSmallintField = class(TLongintField)
  306. protected
  307. function GetDataSize: Word; override;
  308. public
  309. constructor Create(AOwner: TComponent); override;
  310. end;
  311. { TWordField }
  312. TWordField = class(TLongintField)
  313. protected
  314. function GetDataSize: Word; override;
  315. public
  316. constructor Create(AOwner: TComponent); override;
  317. end;
  318. { TAutoIncField }
  319. TAutoIncField = class(TLongintField)
  320. Protected
  321. Procedure SetAsLongInt(AValue : Longint); override;
  322. public
  323. constructor Create(AOwner: TComponent); override;
  324. end;
  325. { TFloatField }
  326. TFloatField = class(TNumericField)
  327. private
  328. FMaxValue : Extended;
  329. FMinValue : Extended;
  330. FPrecision : Longint;
  331. protected
  332. function GetAsFloat: Extended; override;
  333. function GetAsLongint: Longint; override;
  334. function GetAsString: string; override;
  335. function GetDataSize: Word; override;
  336. procedure GetText(var theText: string; DisplayText: Boolean); override;
  337. procedure SetAsFloat(AValue: Extended); override;
  338. procedure SetAsLongint(AValue: Longint); override;
  339. procedure SetAsString(const AValue: string); override;
  340. public
  341. constructor Create(AOwner: TComponent); override;
  342. Function CheckRange(AValue : Extended) : Boolean;
  343. property Value: Extended read GetAsFloat write SetAsFloat;
  344. published
  345. property MaxValue: Extended read FMaxValue write FMaxValue;
  346. property MinValue: Extended read FMinValue write FMinValue;
  347. property Precision: Longint read FPrecision write FPrecision default 15;
  348. end;
  349. { TBooleanField }
  350. TBooleanField = class(TField)
  351. private
  352. FDisplayValues : String;
  353. // First byte indicates uppercase or not.
  354. FDisplays : Array[Boolean,Boolean] of string;
  355. Procedure SetDisplayValues(AValue : String);
  356. protected
  357. function GetAsBoolean: Boolean; override;
  358. function GetAsString: string; override;
  359. function GetDataSize: Word; override;
  360. function GetDefaultWidth: Longint; override;
  361. procedure SetAsBoolean(AValue: Boolean); override;
  362. procedure SetAsString(const AValue: string); override;
  363. public
  364. constructor Create(AOwner: TComponent); override;
  365. property Value: Boolean read GetAsBoolean write SetAsBoolean;
  366. published
  367. property DisplayValues: string read FDisplayValues write SetDisplayValues;
  368. end;
  369. { TDateTimeField }
  370. TDateTimeField = class(TField)
  371. private
  372. FDisplayFormat : String;
  373. protected
  374. function GetAsDateTime: TDateTime; override;
  375. function GetAsFloat: Extended; override;
  376. function GetAsString: string; override;
  377. function GetDataSize: Word; override;
  378. procedure GetText(var theText: string; DisplayText: Boolean); override;
  379. procedure SetAsDateTime(AValue: TDateTime); override;
  380. procedure SetAsFloat(AValue: Extended); override;
  381. procedure SetAsString(const AValue: string); override;
  382. public
  383. constructor Create(AOwner: TComponent); override;
  384. property Value: TDateTime read GetAsDateTime write SetAsDateTime;
  385. published
  386. property DisplayFormat: string read FDisplayFormat write FDisplayFormat;
  387. end;
  388. { TDateField }
  389. TDateField = class(TDateTimeField)
  390. protected
  391. function GetDataSize: Word; override;
  392. public
  393. constructor Create(AOwner: TComponent); override;
  394. end;
  395. { TTimeField }
  396. TTimeField = class(TDateTimeField)
  397. protected
  398. function GetDataSize: Word; override;
  399. public
  400. constructor Create(AOwner: TComponent); override;
  401. end;
  402. { TBinaryField }
  403. TBinaryField = class(TField)
  404. protected
  405. class procedure CheckTypeSize(AValue: Longint); override;
  406. function GetAsString: string; override;
  407. procedure GetText(var TheText: string; DisplayText: Boolean); override;
  408. procedure SetAsString(const AValue: string); override;
  409. procedure SetText(const AValue: string); override;
  410. public
  411. constructor Create(AOwner: TComponent); override;
  412. published
  413. property Size default 16;
  414. end;
  415. { TBytesField }
  416. TBytesField = class(TBinaryField)
  417. protected
  418. function GetDataSize: Word; override;
  419. public
  420. constructor Create(AOwner: TComponent); override;
  421. end;
  422. { TVarBytesField }
  423. TVarBytesField = class(TBytesField)
  424. protected
  425. function GetDataSize: Word; override;
  426. public
  427. constructor Create(AOwner: TComponent); override;
  428. end;
  429. { TBCDField }
  430. TBCDField = class(TNumericField)
  431. private
  432. protected
  433. class procedure CheckTypeSize(AValue: Longint); override;
  434. function GetAsFloat: Extended; override;
  435. function GetAsLongint: Longint; override;
  436. function GetAsString: string; override;
  437. function GetDataSize: Word; override;
  438. function GetDefaultWidth: Longint; override;
  439. procedure GetText(var TheText: string; DisplayText: Boolean); override;
  440. procedure SetAsFloat(AValue: Extended); override;
  441. procedure SetAsLongint(AValue: Longint); override;
  442. procedure SetAsString(const AValue: string); override;
  443. public
  444. constructor Create(AOwner: TComponent); override;
  445. published
  446. property Size default 4;
  447. end;
  448. { TBlobField }
  449. TBlobStreamMode = (bmRead, bmWrite, bmReadWrite);
  450. TBlobType = ftBlob..ftTypedBinary;
  451. TBlobField = class(TField)
  452. private
  453. FBlobSize : Longint;
  454. FBlobType : TBlobType;
  455. FModified : Boolean;
  456. FTransliterate : Boolean;
  457. Function GetBlobStream (Mode : TBlobStreamMode) : TStream;
  458. protected
  459. procedure AssignTo(Dest: TPersistent); override;
  460. procedure FreeBuffers; override;
  461. function GetAsString: string; override;
  462. function GetBlobSize: Longint; virtual;
  463. function GetIsNull: Boolean; override;
  464. procedure GetText(var TheText: string; DisplayText: Boolean); override;
  465. procedure SetAsString(const AValue: string); override;
  466. procedure SetText(const AValue: string); override;
  467. public
  468. constructor Create(AOwner: TComponent); override;
  469. procedure Assign(Source: TPersistent); override;
  470. procedure Clear; override;
  471. class function IsBlob: Boolean; override;
  472. procedure LoadFromFile(const FileName: string);
  473. procedure LoadFromStream(Stream: TStream);
  474. procedure SaveToFile(const FileName: string);
  475. procedure SaveToStream(Stream: TStream);
  476. procedure SetFieldType(AValue: TFieldType); override;
  477. property BlobSize: Longint read FBlobSize;
  478. property Modified: Boolean read FModified write FModified;
  479. property Value: string read GetAsString write SetAsString;
  480. property Transliterate: Boolean read FTransliterate write FTransliterate;
  481. published
  482. property BlobType: TBlobType read FBlobType write FBlobType;
  483. property Size default 0;
  484. end;
  485. { TMemoField }
  486. TMemoField = class(TBlobField)
  487. public
  488. constructor Create(AOwner: TComponent); override;
  489. published
  490. property Transliterate default True;
  491. end;
  492. { TGraphicField }
  493. TGraphicField = class(TBlobField)
  494. public
  495. constructor Create(AOwner: TComponent); override;
  496. end;
  497. { TIndexDef }
  498. TIndexDefs = class;
  499. TIndexOptions = set of (ixPrimary, ixUnique, ixDescending,
  500. ixCaseInsensitive, ixExpression);
  501. TIndexDef = class
  502. Private
  503. FExpression : String;
  504. FFields : String;
  505. FName : String;
  506. FOptions : TIndexOptions;
  507. FSource : String;
  508. public
  509. constructor Create(Owner: TIndexDefs; const AName, TheFields: string;
  510. TheOptions: TIndexOptions);
  511. destructor Destroy; override;
  512. property Expression: string read FExpression;
  513. property Fields: string read FFields;
  514. property Name: string read FName;
  515. property Options: TIndexOptions read FOptions;
  516. property Source: string read FSource write FSource;
  517. end;
  518. { TIndexDefs }
  519. TIndexDefs = class
  520. Private
  521. FCount : Longint;
  522. FUpDated : Boolean;
  523. Function GetItem (Index : longint) : TindexDef;
  524. public
  525. constructor Create(DataSet: TDataSet);
  526. destructor Destroy; override;
  527. procedure Add(const Name, Fields: string; Options: TIndexOptions);
  528. procedure Assign(IndexDefs: TIndexDefs);
  529. procedure Clear;
  530. function FindIndexForFields(const Fields: string): TIndexDef;
  531. function GetIndexForFields(const Fields: string;
  532. CaseInsensitive: Boolean): TIndexDef;
  533. function IndexOf(const Name: string): Longint;
  534. procedure Update;
  535. property Count: Longint read FCount;
  536. property Items[Index: Longint]: TIndexDef read GetItem; default;
  537. property Updated: Boolean read FUpdated write FUpdated;
  538. end;
  539. { TCheckConstraint }
  540. TCheckConstraint = class(TCollectionItem)
  541. Private
  542. FCustomConstraint : String;
  543. FErrorMessage : String;
  544. FFromDictionary : Boolean;
  545. FImportedConstraint : String;
  546. public
  547. procedure Assign(Source: TPersistent); override;
  548. // function GetDisplayName: string; override;
  549. published
  550. property CustomConstraint: string read FCustomConstraint write FCustomConstraint;
  551. property ErrorMessage: string read FErrorMessage write FErrorMessage;
  552. property FromDictionary: Boolean read FFromDictionary write FFromDictionary;
  553. property ImportedConstraint: string read FImportedConstraint write FImportedConstraint;
  554. end;
  555. { TCheckConstraints }
  556. TCheckConstraints = class(TCollection)
  557. Private
  558. Function GetItem(Index : Longint) : TCheckConstraint;
  559. Procedure SetItem(index : Longint; Value : TCheckConstraint);
  560. protected
  561. function GetOwner: TPersistent; override;
  562. public
  563. constructor Create(Owner: TPersistent);
  564. function Add: TCheckConstraint;
  565. property Items[Index: Longint]: TCheckConstraint read GetItem write SetItem; default;
  566. end;
  567. { TFields }
  568. Tfields = Class(TObject)
  569. Private
  570. FDataset : TDataset;
  571. FFieldList : TList;
  572. FOnChange : TNotifyEvent;
  573. FValidFieldKinds : TFieldKinds;
  574. Protected
  575. Procedure Changed;
  576. Procedure CheckfieldKind(Fieldkind : TFieldKind; Field : TField);
  577. Function GetCount : Longint;
  578. Function GetField (Index : longint) : TField;
  579. Procedure SetFieldIndex (Field : TField;Value : Integer);
  580. Property OnChange : TNotifyEvent Read FOnChange Write FOnChange;
  581. Property ValidFieldKinds : TFieldKinds Read FValidFieldKinds;
  582. Public
  583. Constructor Create(ADataset : TDataset);
  584. Destructor Destroy;override;
  585. Procedure Add(Field : TField);
  586. Procedure CheckFieldName (Const Value : String);
  587. Procedure CheckFieldNames (Const Value : String);
  588. Procedure Clear;
  589. Function FindField (Const Value : String) : TField;
  590. Function FieldByName (Const Value : String) : TField;
  591. Function FieldByNumber(FieldNo : Integer) : TField;
  592. Procedure GetFieldNames (Values : TStrings);
  593. Function IndexOf(Field : TField) : Longint;
  594. procedure Remove(Value : TField);
  595. Property Count : Integer Read GetCount;
  596. Property Dataset : TDataset Read FDataset;
  597. Property Fields [Index : Integer] : TField Read GetField; default;
  598. end;
  599. { TDataSet }
  600. TBookmark = Pointer;
  601. TBookmarkStr = string;
  602. PBookmarkFlag = ^TBookmarkFlag;
  603. TBookmarkFlag = (bfCurrent, bfBOF, bfEOF, bfInserted);
  604. PBufferList = ^TBufferList;
  605. TBufferList = array[0..dsMaxBufferCount - 1] of PChar;
  606. TGetMode = (gmCurrent, gmNext, gmPrior);
  607. TGetResult = (grOK, grBOF, grEOF, grError);
  608. TResyncMode = set of (rmExact, rmCenter);
  609. TDataAction = (daFail, daAbort, daRetry);
  610. TUpdateKind = (ukModify, ukInsert, ukDelete);
  611. TLocateOption = (loCaseInsensitive, loPartialKey);
  612. TLocateOptions = set of TLocateOption;
  613. TDataOperation = procedure of object;
  614. TDataSetNotifyEvent = procedure(DataSet: TDataSet) of object;
  615. TDataSetErrorEvent = procedure(DataSet: TDataSet; E: EDatabaseError;
  616. var Action: TDataAction) of object;
  617. TFilterOption = (foCaseInsensitive, foNoPartialCompare);
  618. TFilterOptions = set of TFilterOption;
  619. TFilterRecordEvent = procedure(DataSet: TDataSet;
  620. var Accept: Boolean) of object;
  621. TDatasetClass = Class of TDataset;
  622. TBufferArray = ^pchar;
  623. TDataSet = class(TComponent)
  624. Private
  625. FActive: Boolean;
  626. FActiveRecord: Longint;
  627. FAfterCancel: TDataSetNotifyEvent;
  628. FAfterClose: TDataSetNotifyEvent;
  629. FAfterDelete: TDataSetNotifyEvent;
  630. FAfterEdit: TDataSetNotifyEvent;
  631. FAfterInsert: TDataSetNotifyEvent;
  632. FAfterOpen: TDataSetNotifyEvent;
  633. FAfterPost: TDataSetNotifyEvent;
  634. FAfterScroll: TDataSetNotifyEvent;
  635. FAutoCalcFields: Boolean;
  636. FBOF: Boolean;
  637. FBeforeCancel: TDataSetNotifyEvent;
  638. FBeforeClose: TDataSetNotifyEvent;
  639. FBeforeDelete: TDataSetNotifyEvent;
  640. FBeforeEdit: TDataSetNotifyEvent;
  641. FBeforeInsert: TDataSetNotifyEvent;
  642. FBeforeOpen: TDataSetNotifyEvent;
  643. FBeforePost: TDataSetNotifyEvent;
  644. FBeforeScroll: TDataSetNotifyEvent;
  645. FBlobFieldCount: Longint;
  646. FBookmark: TBookmarkStr;
  647. FBookmarkSize: Longint;
  648. FBuffers : TBufferArray;
  649. FBufferCount: Longint;
  650. FCalcBuffer: PChar;
  651. FCalcFieldsSize: Longint;
  652. FCanModify: Boolean;
  653. FConstraints: TCheckConstraints;
  654. FCurrentRecord: Longint;
  655. FDefaultFields: Boolean;
  656. FEOF: Boolean;
  657. FFieldList : TFields;
  658. FFieldCount : Longint;
  659. FFieldDefs: TFieldDefs;
  660. FFilterOptions: TFilterOptions;
  661. FFilterText: string;
  662. FFiltered: Boolean;
  663. FFound: Boolean;
  664. FInternalCalcFields: Boolean;
  665. FModified: Boolean;
  666. FOnCalcFields: TDataSetNotifyEvent;
  667. FOnDeleteError: TDataSetErrorEvent;
  668. FOnEditError: TDataSetErrorEvent;
  669. FOnFilterRecord: TFilterRecordEvent;
  670. FOnNewRecord: TDataSetNotifyEvent;
  671. FOnPostError: TDataSetErrorEvent;
  672. FRecNo: Longint;
  673. FRecordCount: Longint;
  674. FRecordSize: Word;
  675. FState: TDataSetState;
  676. Procedure DoInsertAppend(DoAppend : Boolean);
  677. Procedure DoInternalOpen;
  678. Procedure DoInternalClose;
  679. Function GetBuffer (Index : longint) : Pchar;
  680. Function GetField (Index : Longint) : TField;
  681. Procedure RemoveField (Field : TField);
  682. Procedure SetActive (Value : Boolean);
  683. Procedure SetField (Index : Longint;Value : TField);
  684. Procedure ShiftBuffers (Offset,Distance : Longint);
  685. Function TryDoing (P : TDataOperation; Ev : TDatasetErrorEvent) : Boolean;
  686. Procedure UpdateFieldDefs;
  687. protected
  688. procedure ActivateBuffers; virtual;
  689. procedure BindFields(Binding: Boolean);
  690. function BookmarkAvailable: Boolean;
  691. procedure CalculateFields(Buffer: PChar); virtual;
  692. procedure CheckActive; virtual;
  693. procedure CheckInactive; virtual;
  694. procedure ClearBuffers; virtual;
  695. procedure ClearCalcFields(Buffer: PChar); virtual;
  696. procedure CloseBlob(Field: TField); virtual;
  697. procedure CloseCursor; virtual;
  698. procedure CreateFields;
  699. procedure DataEvent(Event: TDataEvent; Info: Longint); virtual;
  700. procedure DestroyFields; virtual;
  701. procedure DoAfterCancel; virtual;
  702. procedure DoAfterClose; virtual;
  703. procedure DoAfterDelete; virtual;
  704. procedure DoAfterEdit; virtual;
  705. procedure DoAfterInsert; virtual;
  706. procedure DoAfterOpen; virtual;
  707. procedure DoAfterPost; virtual;
  708. procedure DoAfterScroll; virtual;
  709. procedure DoBeforeCancel; virtual;
  710. procedure DoBeforeClose; virtual;
  711. procedure DoBeforeDelete; virtual;
  712. procedure DoBeforeEdit; virtual;
  713. procedure DoBeforeInsert; virtual;
  714. procedure DoBeforeOpen; virtual;
  715. procedure DoBeforePost; virtual;
  716. procedure DoBeforeScroll; virtual;
  717. procedure DoOnCalcFields; virtual;
  718. procedure DoOnNewRecord; virtual;
  719. function FieldByNumber(FieldNo: Longint): TField;
  720. function FindRecord(Restart, GoForward: Boolean): Boolean; virtual;
  721. procedure FreeFieldBuffers; virtual;
  722. function GetBookmarkStr: TBookmarkStr; virtual;
  723. procedure GetCalcFields(Buffer: PChar); virtual;
  724. function GetCanModify: Boolean; virtual;
  725. procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  726. function GetFieldClass(FieldType: TFieldType): TFieldClass; virtual;
  727. Function GetfieldCount : Integer;
  728. function GetIsIndexField(Field: TField): Boolean; virtual;
  729. function GetNextRecords: Longint; virtual;
  730. function GetNextRecord: Boolean; virtual;
  731. function GetPriorRecords: Longint; virtual;
  732. function GetPriorRecord: Boolean; virtual;
  733. function GetRecordCount: Longint; virtual;
  734. function GetRecNo: Longint; virtual;
  735. procedure InitFieldDefs; virtual;
  736. procedure InitRecord(Buffer: PChar); virtual;
  737. procedure InternalCancel; virtual;
  738. procedure InternalEdit; virtual;
  739. procedure InternalRefresh; virtual;
  740. procedure Loaded; override;
  741. procedure OpenCursor(InfoQuery: Boolean); virtual;
  742. procedure RefreshInternalCalcFields(Buffer: PChar); virtual;
  743. Function RequiredBuffers : longint;
  744. procedure RestoreState(const Value: TDataSetState);
  745. procedure SetBookmarkStr(const Value: TBookmarkStr); virtual;
  746. procedure SetBufListSize(Value: Longint);
  747. procedure SetChildOrder(Component: TComponent; Order: Longint); override;
  748. procedure SetCurrentRecord(Index: Longint); virtual;
  749. procedure SetFiltered(Value: Boolean); virtual;
  750. procedure SetFilterOptions(Value: TFilterOptions); virtual;
  751. procedure SetFilterText(const Value: string); virtual;
  752. procedure SetFound(const Value: Boolean);
  753. procedure SetModified(Value: Boolean);
  754. procedure SetName(const Value: TComponentName); override;
  755. procedure SetOnFilterRecord(const Value: TFilterRecordEvent); virtual;
  756. procedure SetRecNo(Value: Longint); virtual;
  757. procedure SetState(Value: TDataSetState);
  758. function SetTempState(const Value: TDataSetState): TDataSetState;
  759. function TempBuffer: PChar;
  760. procedure UpdateIndexDefs; virtual;
  761. property ActiveRecord: Longint read FActiveRecord;
  762. property CurrentRecord: Longint read FCurrentRecord;
  763. property BlobFieldCount: Longint read FBlobFieldCount;
  764. property BookmarkSize: Longint read FBookmarkSize write FBookmarkSize;
  765. property Buffers[Index: Longint]: PChar read GetBuffer;
  766. property BufferCount: Longint read FBufferCount;
  767. property CalcBuffer: PChar read FCalcBuffer;
  768. property CalcFieldsSize: Longint read FCalcFieldsSize;
  769. property InternalCalcFields: Boolean read FInternalCalcFields;
  770. property Constraints: TCheckConstraints read FConstraints write FConstraints;
  771. protected { abstract methods }
  772. function AllocRecordBuffer: PChar; virtual; abstract;
  773. procedure FreeRecordBuffer(var Buffer: PChar); virtual; abstract;
  774. procedure GetBookmarkData(Buffer: PChar; Data: Pointer); virtual; abstract;
  775. function GetBookmarkFlag(Buffer: PChar): TBookmarkFlag; virtual; abstract;
  776. function GetFieldData(Field: TField; Buffer: Pointer): Boolean; virtual; abstract;
  777. function GetRecord(Buffer: PChar; GetMode: TGetMode; DoCheck: Boolean): TGetResult; virtual; abstract;
  778. function GetRecordSize: Word; virtual; abstract;
  779. procedure InternalAddRecord(Buffer: Pointer; Append: Boolean); virtual; abstract;
  780. procedure InternalClose; virtual; abstract;
  781. procedure InternalDelete; virtual; abstract;
  782. procedure InternalFirst; virtual; abstract;
  783. procedure InternalGotoBookmark(ABookmark: Pointer); virtual; abstract;
  784. procedure InternalHandleException; virtual; abstract;
  785. procedure InternalInitFieldDefs; virtual; abstract;
  786. procedure InternalInitRecord(Buffer: PChar); virtual; abstract;
  787. procedure InternalLast; virtual; abstract;
  788. procedure InternalOpen; virtual; abstract;
  789. procedure InternalPost; virtual; abstract;
  790. procedure InternalSetToRecord(Buffer: PChar); virtual; abstract;
  791. function IsCursorOpen: Boolean; virtual; abstract;
  792. procedure SetBookmarkFlag(Buffer: PChar; Value: TBookmarkFlag); virtual; abstract;
  793. procedure SetBookmarkData(Buffer: PChar; Data: Pointer); virtual; abstract;
  794. procedure SetFieldData(Field: TField; Buffer: Pointer); virtual; abstract;
  795. public
  796. constructor Create(AOwner: TComponent); override;
  797. destructor Destroy; override;
  798. function ActiveBuffer: PChar;
  799. procedure Append;
  800. procedure AppendRecord(const Values: array of const);
  801. function BookmarkValid(ABookmark: TBookmark): Boolean; virtual;
  802. procedure Cancel; virtual;
  803. procedure CheckBrowseMode;
  804. procedure ClearFields;
  805. procedure Close;
  806. function ControlsDisabled: Boolean;
  807. function CompareBookmarks(Bookmark1, Bookmark2: TBookmark): Longint; virtual;
  808. function CreateBlobStream(Field: TField; Mode: TBlobStreamMode): TStream; virtual;
  809. procedure CursorPosChanged;
  810. procedure Delete;
  811. procedure DisableControls;
  812. procedure Edit;
  813. procedure EnableControls;
  814. function FieldByName(const FieldName: string): TField;
  815. function FindField(const FieldName: string): TField;
  816. function FindFirst: Boolean;
  817. function FindLast: Boolean;
  818. function FindNext: Boolean;
  819. function FindPrior: Boolean;
  820. procedure First;
  821. procedure FreeBookmark(ABookmark: TBookmark); virtual;
  822. function GetBookmark: TBookmark; virtual;
  823. function GetCurrentRecord(Buffer: PChar): Boolean; virtual;
  824. procedure GetFieldList(List: TList; const FieldNames: string);
  825. procedure GetFieldNames(List: TStrings);
  826. procedure GotoBookmark(ABookmark: TBookmark);
  827. procedure Insert;
  828. procedure InsertRecord(const Values: array of const);
  829. function IsEmpty: Boolean;
  830. function IsSequenced: Boolean; virtual;
  831. procedure Last;
  832. function MoveBy(Distance: Longint): Longint;
  833. procedure Next;
  834. procedure Open;
  835. procedure Post; virtual;
  836. procedure Prior;
  837. procedure Refresh;
  838. procedure Resync(Mode: TResyncMode); virtual;
  839. procedure SetFields(const Values: array of const);
  840. procedure Translate(Src, Dest: PChar; ToOem: Boolean); virtual;
  841. procedure UpdateCursorPos;
  842. procedure UpdateRecord;
  843. property BOF: Boolean read FBOF;
  844. property Bookmark: TBookmarkStr read GetBookmarkStr write SetBookmarkStr;
  845. property CanModify: Boolean read GetCanModify;
  846. property DefaultFields: Boolean read FDefaultFields;
  847. property EOF: Boolean read FEOF;
  848. property FieldCount: Longint read GetFieldCount;
  849. property FieldDefs: TFieldDefs read FFieldDefs write FFieldDefs;
  850. property Fields[Index: Longint]: TField read GetField write SetField;
  851. property Found: Boolean read FFound;
  852. property Modified: Boolean read FModified;
  853. property RecordCount: Longint read GetRecordCount;
  854. property RecNo: Longint read FRecNo write FRecNo;
  855. property RecordSize: Word read FRecordSize;
  856. property State: TDataSetState read FState;
  857. property Fields : TFields Read FFieldList;
  858. property Filter: string read FFilterText write FFilterText;
  859. property Filtered: Boolean read FFiltered write FFiltered default False;
  860. property FilterOptions: TFilterOptions read FFilterOptions write FFilterOptions;
  861. property Active: Boolean read FActive write SetActive default False;
  862. property AutoCalcFields: Boolean read FAutoCalcFields write FAutoCalcFields;
  863. property BeforeOpen: TDataSetNotifyEvent read FBeforeOpen write FBeforeOpen;
  864. property AfterOpen: TDataSetNotifyEvent read FAfterOpen write FAfterOpen;
  865. property BeforeClose: TDataSetNotifyEvent read FBeforeClose write FBeforeClose;
  866. property AfterClose: TDataSetNotifyEvent read FAfterClose write FAfterClose;
  867. property BeforeInsert: TDataSetNotifyEvent read FBeforeInsert write FBeforeInsert;
  868. property AfterInsert: TDataSetNotifyEvent read FAfterInsert write FAfterInsert;
  869. property BeforeEdit: TDataSetNotifyEvent read FBeforeEdit write FBeforeEdit;
  870. property AfterEdit: TDataSetNotifyEvent read FAfterEdit write FAfterEdit;
  871. property BeforePost: TDataSetNotifyEvent read FBeforePost write FBeforePost;
  872. property AfterPost: TDataSetNotifyEvent read FAfterPost write FAfterPost;
  873. property BeforeCancel: TDataSetNotifyEvent read FBeforeCancel write FBeforeCancel;
  874. property AfterCancel: TDataSetNotifyEvent read FAfterCancel write FAfterCancel;
  875. property BeforeDelete: TDataSetNotifyEvent read FBeforeDelete write FBeforeDelete;
  876. property AfterDelete: TDataSetNotifyEvent read FAfterDelete write FAfterDelete;
  877. property BeforeScroll: TDataSetNotifyEvent read FBeforeScroll write FBeforeScroll;
  878. property AfterScroll: TDataSetNotifyEvent read FAfterScroll write FAfterScroll;
  879. property OnCalcFields: TDataSetNotifyEvent read FOnCalcFields write FOnCalcFields;
  880. property OnDeleteError: TDataSetErrorEvent read FOnDeleteError write FOnDeleteError;
  881. property OnEditError: TDataSetErrorEvent read FOnEditError write FOnEditError;
  882. property OnFilterRecord: TFilterRecordEvent read FOnFilterRecord write SetOnFilterRecord;
  883. property OnNewRecord: TDataSetNotifyEvent read FOnNewRecord write FOnNewRecord;
  884. property OnPostError: TDataSetErrorEvent read FOnPostError write FOnPostError;
  885. end;
  886. { TDBDataset }
  887. TDBDatasetClass = Class of TDBDataset;
  888. TDBDataset = Class(TDataset)
  889. Private
  890. FDatabase : TDatabase;
  891. Procedure SetDatabase (Value : TDatabase);
  892. Published
  893. Property DataBase : TDatabase Read FDatabase Write SetDatabase;
  894. end;
  895. { TDatabase }
  896. TLoginEvent = procedure(Database: TDatabase;
  897. LoginParams: TStrings) of object;
  898. TDatabaseClass = Class Of TDatabase;
  899. TDatabase = class(TComponent)
  900. private
  901. FConnected : Boolean;
  902. FDataBaseName : String;
  903. FDataSets : TList;
  904. FDirectOry : String;
  905. FKeepConnection : Boolean;
  906. FLoginPrompt : Boolean;
  907. FOnLogin : TLoginEvent;
  908. FParams : TStrings;
  909. FSQLBased : Boolean;
  910. Function GetDataSetCount : Longint;
  911. Function GetDataset(Index : longint) : TDBDataset;
  912. procedure SetConnected (Value : boolean);
  913. procedure RegisterDataset (DS : TDBDataset);
  914. procedure UnRegisterDataset (DS : TDBDataset);
  915. procedure RemoveDataSets;
  916. protected
  917. Procedure CheckConnected;
  918. Procedure CheckDisConnected;
  919. procedure Loaded; override;
  920. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  921. Procedure DoInternalConnect; Virtual;Abstract;
  922. Procedure DoInternalDisConnect; Virtual;Abstract;
  923. public
  924. constructor Create(AOwner: TComponent); override;
  925. destructor Destroy; override;
  926. procedure Close;
  927. procedure Open;
  928. procedure CloseDataSets;
  929. procedure StartTransaction; virtual; abstract;
  930. procedure EndTransaction; virtual; abstract;
  931. property DataSetCount: Longint read GetDataSetCount;
  932. property DataSets[Index: Longint]: TDBDataSet read GetDataSet;
  933. property Directory: string read FDirectory write FDirectory;
  934. property IsSQLBased: Boolean read FSQLBased;
  935. published
  936. property Connected: Boolean read FConnected write SetConnected;
  937. property DatabaseName: string read FDatabaseName write FDatabaseName;
  938. property KeepConnection: Boolean read FKeepConnection write FKeepConnection;
  939. property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt;
  940. property Params : TStrings read FParams Write FParams;
  941. property OnLogin: TLoginEvent read FOnLogin write FOnLogin;
  942. end;
  943. Const
  944. Fieldtypenames : Array [TFieldType] of String[15] =
  945. ( 'Unknown',
  946. 'String',
  947. 'Smallint',
  948. 'Integer',
  949. 'Word',
  950. 'Boolean',
  951. 'Float',
  952. 'Date',
  953. 'Time',
  954. 'DateTime',
  955. 'Bytes',
  956. 'VarBytes',
  957. 'AutoInc',
  958. 'Blob',
  959. 'Memo',
  960. 'Graphic',
  961. 'FmtMemo',
  962. 'ParadoxOle',
  963. 'DBaseOle',
  964. 'TypedBinary',
  965. 'Cursor'
  966. );
  967. { Auxiliary functions }
  968. Procedure DatabaseError (Const Msg : String);
  969. Procedure DatabaseError (Const Msg : String; Comp : TComponent);
  970. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of Const);
  971. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of const;
  972. Comp : TComponent);
  973. implementation
  974. { ---------------------------------------------------------------------
  975. Auxiliary functions
  976. ---------------------------------------------------------------------}
  977. Procedure DatabaseError (Const Msg : String);
  978. begin
  979. Raise EDataBaseError.Create(Msg);
  980. end;
  981. Procedure DatabaseError (Const Msg : String; Comp : TComponent);
  982. begin
  983. Raise EDatabaseError.CreateFmt('%s : %s',[Comp.Name,Msg]);
  984. end;
  985. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of Const);
  986. begin
  987. Raise EDatabaseError.CreateFmt(Fmt,Args);
  988. end;
  989. Procedure DatabaseErrorFmt (Const Fmt : String; Args : Array Of const;
  990. Comp : TComponent);
  991. begin
  992. Raise EDatabaseError.CreateFmt(Format('%s : %s',[Comp.Name,Fmt]),Args);
  993. end;
  994. {$i dbs.inc}
  995. { TIndexDef }
  996. constructor TIndexDef.Create(Owner: TIndexDefs; const AName, TheFields: string;
  997. TheOptions: TIndexOptions);
  998. begin
  999. //!! To be implemented
  1000. end;
  1001. destructor TIndexDef.Destroy;
  1002. begin
  1003. //!! To be implemented
  1004. end;
  1005. { TIndexDefs }
  1006. Function TIndexDefs.GetItem (Index : longint) : TindexDef;
  1007. begin
  1008. //!! To be implemented
  1009. end;
  1010. constructor TIndexDefs.Create(DataSet: TDataSet);
  1011. begin
  1012. //!! To be implemented
  1013. end;
  1014. destructor TIndexDefs.Destroy;
  1015. begin
  1016. //!! To be implemented
  1017. end;
  1018. procedure TIndexDefs.Add(const Name, Fields: string; Options: TIndexOptions);
  1019. begin
  1020. //!! To be implemented
  1021. end;
  1022. procedure TIndexDefs.Assign(IndexDefs: TIndexDefs);
  1023. begin
  1024. //!! To be implemented
  1025. end;
  1026. procedure TIndexDefs.Clear;
  1027. begin
  1028. //!! To be implemented
  1029. end;
  1030. function TIndexDefs.FindIndexForFields(const Fields: string): TIndexDef;
  1031. begin
  1032. //!! To be implemented
  1033. end;
  1034. function TIndexDefs.GetIndexForFields(const Fields: string;
  1035. CaseInsensitive: Boolean): TIndexDef;
  1036. begin
  1037. //!! To be implemented
  1038. end;
  1039. function TIndexDefs.IndexOf(const Name: string): Longint;
  1040. begin
  1041. //!! To be implemented
  1042. end;
  1043. procedure TIndexDefs.Update;
  1044. begin
  1045. //!! To be implemented
  1046. end;
  1047. { TCheckConstraint }
  1048. procedure TCheckConstraint.Assign(Source: TPersistent);
  1049. begin
  1050. //!! To be implemented
  1051. end;
  1052. { TCheckConstraints }
  1053. Function TCheckConstraints.GetItem(Index : Longint) : TCheckConstraint;
  1054. begin
  1055. //!! To be implemented
  1056. end;
  1057. Procedure TCheckConstraints.SetItem(index : Longint; Value : TCheckConstraint);
  1058. begin
  1059. //!! To be implemented
  1060. end;
  1061. function TCheckConstraints.GetOwner: TPersistent;
  1062. begin
  1063. //!! To be implemented
  1064. end;
  1065. constructor TCheckConstraints.Create(Owner: TPersistent);
  1066. begin
  1067. //!! To be implemented
  1068. end;
  1069. function TCheckConstraints.Add: TCheckConstraint;
  1070. begin
  1071. //!! To be implemented
  1072. end;
  1073. {$i dataset.inc}
  1074. {$i fields.inc}
  1075. {$i database.inc}
  1076. end.
  1077. {
  1078. $Log$
  1079. Revision 1.8 2000-01-07 01:24:32 peter
  1080. * updated copyright to 2000
  1081. Revision 1.7 2000/01/06 01:20:32 peter
  1082. * moved out of packages/ back to topdir
  1083. Revision 1.1 2000/01/03 19:33:05 peter
  1084. * moved to packages dir
  1085. Revision 1.5 1999/11/12 22:53:32 michael
  1086. + Added append() insert() tested append. Datetime as string works now
  1087. Revision 1.4 1999/11/11 17:31:09 michael
  1088. + Added Checks for all simple field types.
  1089. + Initial implementation of Insert/Append
  1090. Revision 1.3 1999/11/09 13:33:47 peter
  1091. * reallocmem fixes
  1092. Revision 1.2 1999/10/24 17:07:54 michael
  1093. + Added copyright header
  1094. }