📄 myldbmain.pas
字号:
FMaxValue: TMYLDBVariant;
// Autoinc settings
FAutoincIncrement: Int64;
FAutoincInitialValue: Int64;
FAutoincMinValue: Int64;
FAutoincMaxValue: Int64;
FAutoincCycled: Boolean;
FBLOBCompressionAlgorithm: TCompressionAlgorithm;
FBLOBCompressionMode: Byte;
FBLOBBlockSize: Integer;
public
procedure Assign(Source: TMYLDBAdvFieldDef);
constructor Create;
destructor Destroy; override;
public
property Name: String read FName write FName;
property ObjectID: TMYLDBObjectID read FObjectID write FObjectID;
property DataType: TMYLDBAdvancedFieldType read FDataType write FDataType;
property Required: Boolean read FRequired write FRequired;
property Size: Integer read FSize write FSize;
property DefaultValue: TMYLDBVariant read FDefaultValue;
property MinValue: TMYLDBVariant read FMinValue;
property MaxValue: TMYLDBVariant read FMaxValue;
property AutoincIncrement: Int64 read FAutoincIncrement write FAutoincIncrement;
property AutoincInitialValue: Int64 read FAutoincInitialValue write FAutoincInitialValue;
property AutoincMinValue: Int64 read FAutoincMinValue write FAutoincMinValue;
property AutoincMaxValue: Int64 read FAutoincMaxValue write FAutoincMaxValue;
property AutoincCycled: Boolean read FAutoincCycled write FAutoincCycled;
property BLOBCompressionAlgorithm: TCompressionAlgorithm read FBLOBCompressionAlgorithm write FBLOBCompressionAlgorithm;
property BLOBCompressionMode: Byte read FBLOBCompressionMode write FBLOBCompressionMode;
property BLOBBlockSize: Integer read FBLOBBlockSize write FBLOBBlockSize;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TMYLDBAdvFieldDefs
//
////////////////////////////////////////////////////////////////////////////////
TMYLDBAdvFieldDefs = class (TObject)
private
FDefsList: TList;
private
function GetCount: Integer;
function GetDef(Index: Integer): TMYLDBAdvFieldDef;
procedure SetDef(Index: Integer; value: TMYLDBAdvFieldDef);
public
procedure Assign(Source: TMYLDBAdvFieldDefs);
constructor Create;
destructor Destroy; override;
function AddFieldDef: TMYLDBAdvFieldDef;
procedure Add(const Name: String; DataType: TMYLDBAdvancedFieldType;
Size: Integer = 0; Required: Boolean = False;
BLOBCompressionAlgorithm: TCompressionAlgorithm = caNone;
BLOBCompressionMode: Byte = 0);
procedure DeleteFieldDef(const FieldName: string);
function Find(const Name: string): TMYLDBAdvFieldDef;
procedure Clear;
public
property Items[Index: Integer]: TMYLDBAdvFieldDef read GetDef write SetDef; default;
property Count: Integer read GetCount;
end;
////////////////////////////////////////////////////////////////////////////////
//
// TMYLDBAdvIndexDef
//
////////////////////////////////////////////////////////////////////////////////
TMYLDBAdvIndexDef = class (TObject)
private
FName: String;
FFields: string;
FDescFields: string;
FCaseInsFields: string;
FOptions: TIndexOptions;
FMaxIndexedSizes: string;
FTemporary: Boolean;
public
constructor Create;
procedure Assign(ASource: TMYLDBAdvIndexDef);
published
property Name: String read FName write FName;
property CaseInsFields: string read FCaseInsFields write FCaseInsFields;
property DescFields: string read FDescFields write FDescFields;
property Fields: string read FFields write FFields;
property Options: TIndexOptions read FOptions write FOptions default [];
property Temporary: Boolean read FTemporary write FTemporary;
property MaxIndexedSizes: string read FMaxIndexedSizes write FMaxIndexedSizes;
end;// TMYLDBAdvIndexDef
////////////////////////////////////////////////////////////////////////////////
//
// TMYLDBAdvIndexDefs
//
////////////////////////////////////////////////////////////////////////////////
TMYLDBAdvIndexDefs = class (TObject)
private
FDefsList: TList;
FDataset: TDataset;
private
function GetCount: Integer;
function GetDef(Index: Integer): TMYLDBAdvIndexDef;
procedure SetDef(Index: Integer; value: TMYLDBAdvIndexDef);
public
procedure Assign(Source: TMYLDBAdvIndexDefs; SkipTemporaryIndexes: Boolean = False);
constructor Create(ADataSet: TDataSet);
destructor Destroy; override;
function AddIndexDef: TMYLDBAdvIndexDef;
procedure Add(const Name, Fields: string; Options: TIndexOptions; Temporary: Boolean = false;
DescFields: string = '';
CaseInsFields: string = '';
MaxIndexedSizes: string = '');
procedure DeleteIndexDef(const IndexName: string);
function Find(const Name: string): TMYLDBAdvIndexDef;
procedure Clear;
procedure Update;
public
property Items[Index: Integer]: TMYLDBAdvIndexDef read GetDef write SetDef; default;
property Count: Integer read GetCount;
end;// TMYLDBAdvIndexDefs
// convert TFieldDefs to MYLDBFieldDefs
procedure ConvertFieldDefsToMYLDBFieldDefs(
FieldDefs: TFieldDefs;
MYLDBFieldDefs: TMYLDBFieldDefs
);
// convert AdvFieldDefs to MYLDBFieldDefs
procedure ConvertAdvFieldDefsToMYLDBFieldDefs(
AdvFieldDefs: TMYLDBAdvFieldDefs;
MYLDBFieldDefs: TMYLDBFieldDefs;
IndexDefs: TMYLDBIndexDefs;
MYLDBConstraintDefs: TMYLDBConstraintDefs;
Temporary: Boolean
);
// Add Unic or Primary Key constraint
function AddConstraintForIndex(
IndexDef: TMYLDBIndexDef;
MYLDBConstraintDefs: TMYLDBConstraintDefs
): TMYLDBConstraintDef;
// convert MYLDBFieldDefs to AdvFieldDefs
procedure ConvertMYLDBFieldDefsToAdvFieldDefs(
VisibleFieldDefs: TMYLDBFieldDefs;
MYLDBFieldDefs: TMYLDBFieldDefs;
MYLDBConstraintDefs: TMYLDBConstraintDefs;
AdvFieldDefs: TMYLDBAdvFieldDefs
);
// convert MYLDBFieldDefs to TFieldDefs
procedure ConvertMYLDBFieldDefsToFieldDefs(
MYLDBFieldDefs: TMYLDBFieldDefs;
MYLDBConstraintDefs: TMYLDBConstraintDefs;
FieldDefs: TFieldDefs
);
// convert AdvFieldDefs to FieldDefs
procedure ConvertAdvFieldDefsToFieldDefs(AdvFieldDefs: TMYLDBAdvFieldDefs; FieldDefs: TFieldDefs);
// convert FieldDefs to AdvFieldDefs
procedure ConvertFieldDefsToAdvFieldDefs(FieldDefs: TFieldDefs; AdvFieldDefs: TMYLDBAdvFieldDefs);
// get string list from string with names
procedure GetNamesList(List: TStrings; const Names: string);
// fill MYLDBIndexDef
procedure FillMYLDBIndexDef(
MYLDBIndexDef: TMYLDBIndexDef;
const Name,
Fields: String;
Options: TIndexOptions;
Temporary: Boolean;
const DescFields: String;
const CaseInsFields: String;
const MaxIndexedSizes: String;
FieldDefs: TFieldDefs
);
// convert TIndexDef to TMYLDBIndexDef
procedure ConvertAdvIndexDefToMYLDBIndexDef(
AdvIndexDef: TMYLDBAdvIndexDef;
MYLDBIndexDef: TMYLDBIndexDef;
FieldDefs: TFieldDefs
);
// convert AdvIndexDefs to TIndexDefs
procedure ConvertAdvIndexDefsToIndexDefs(
AdvIndexDefs: TMYLDBAdvIndexDefs;
IndexDefs: TIndexDefs
);
// convert TIndexDefs to TMYLDBAdvIndexDefs
procedure ConvertIndexDefsToAdvIndexDefs(
IndexDefs: TIndexDefs;
AdvIndexDefs: TMYLDBAdvIndexDefs
);
// convert TAdvIndexDefs to TMYLDBIndexDefs
procedure ConvertAdvIndexDefsToMYLDBIndexDefs(
AdvIndexDefs: TMYLDBAdvIndexDefs;
MYLDBIndexDefs: TMYLDBIndexDefs;
FieldDefs: TFieldDefs
);
// convert MYLDBIndexDef to AdvIndexDef
procedure ConvertMYLDBIndexDefToAdvIndexDef(
MYLDBIndexDef: TMYLDBIndexDef; AdvIndexDef: TMYLDBAdvIndexDef);
// convert MYLDBIndexDefs to TIndexDefs
procedure ConvertMYLDBIndexDefsToAdvIndexDefs(
MYLDBIndexDefs: TMYLDBIndexDefs; AdvIndexDefs: TMYLDBAdvIndexDefs);
// return true if field exists
function FindFieldInFieldDefs(FieldDefs: TFieldDefs; FieldName : string): Boolean;
// compression algorithm
function ConvertCompressionAlgorithmToMYLDBCompressionAlgorithm(
CompressionAlgorithm: TCompressionAlgorithm
): TMYLDBCompressionAlgorithm;
// compression algorithm
function ConvertMYLDBCompressionAlgorithmToCompressionAlgorithm(
CompressionAlgorithm: TMYLDBCompressionAlgorithm
): TCompressionAlgorithm;
// copy records and return error log
//function CopyDatasets(SourceDataset: TDataset; DestinationDataset: TDataset): String;
procedure DbiError(ErrorCode: Integer; ErrorMessage: String = '');
procedure Check(Status: Integer; ErrorMessage: String = '');
var
Sessions: TMYLDBSessionList;
Session: TMYLDBSession;
implementation
uses
{$IFDEF MEMORY_ENGINE}
MYLDBMemEngine,
{$ENDIF}
{$IFDEF TEMPORARY_ENGINE}
MYLDBTempEngine,
{$ENDIF}
{$IFDEF DISK_ENGINE}
MYLDBDiskEngine,
{$IFNDEF NO_DIALOGS}
MYLDBPasswordDialog,
{$ENDIF}
MYLDBExpressions,
{$ENDIF}
{$IFDEF D6H}
DateUtils,
{$ENDIF}
MYLDBDecUtil,
MYLDBBaseEngine;
var
FCSect: TRTLCriticalSection;
CurrentSessionManager: TMYLDBSessionComponentManager;
Initialized: Boolean;
WideStringsStack: TList;
type
////////////////////////////////////////////////////////////////////////////////
//
// TMYLDBQueryDataLink
//
////////////////////////////////////////////////////////////////////////////////
TMYLDBQueryDataLink = class(TDetailDataLink)
private
FQuery: TMYLDBQuery;
protected
procedure ActiveChanged; override;
procedure RecordChanged(Field: TField); override;
function GetDetailDataSet: TDataSet; override;
procedure CheckBrowseMode; override;
public
constructor Create(AQuery: TMYLDBQuery);
end;
////////////////////////////////////////////////////////////////////////////////
//
// TMYLDBQueryDataLink
//
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
// Create
//------------------------------------------------------------------------------
constructor TMYLDBQueryDataLink.Create(AQuery: TMYLDBQuery);
begin
inherited Create;
FQuery := AQuery;
end;// Create
//------------------------------------------------------------------------------
// ActiveChanged
//------------------------------------------------------------------------------
procedure TMYLDBQueryDataLink.ActiveChanged;
begin
if FQuery.Active then
FQuery.RefreshParams;
end;// ActiveChanged
//------------------------------------------------------------------------------
// GetDetailDataSet
//------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -