db.pp 42 KB

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