Unit rdbtool

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

rdbtool contains set of usefull database functions

Updated version compatible with Delphi2010+.

Overview

Functions and Procedures

function GetDataSet(GridOrDSet: TObject): TDataSet;
function GetDSStateStr(GridOrDSet: TObject): string;
procedure AssignGridProps(Source, Dest: TDBGrid);
function IsEditing(GridOrDSet: TObject): boolean;
function IsDataField(Fld: TField): boolean;
function IsSimpleField(Fld: TField): boolean;
function IsApostrField(Fld: TField): boolean;
function IsMemoField(Fld: TField): boolean;
function IsGraphicField(Fld: TField): boolean;
function IsDateTimeField(Fld: TField): boolean;
function IsDateField(Fld: TField): boolean;
function IsTimeField(Fld: TField): boolean;
function GetFldDefs(GetLabels, VisibleFieldOnly, SimpleField, MemoField, AllField, DataFieldOnly: boolean): TGetFldDefs;
function GetFldList(GridOrDSet: TObject; List: TStrings; FldsDef: TGetFldDefs): integer;
function GetFldListValues(Dataset: TDataSet; const FldList: string; const ListSeparator: string = ';'; const ConstMarks: string = '"'): string;
function ShowRecordCount(GridOrDSet: TObject): boolean;
function LocateRecord(F: TField; Value: Variant; CaseSensitive: boolean = false): boolean;
function LocateRecordText(F: TField; const Value: string): boolean;
function FillTextMask(const Mask: string; Dataset: TDataSet; const MaskStrStart: string = '<<'; const MaskStrStop: string = '>>'): string;
procedure AddRecordEx(G: TDBGrid; Insert: boolean = false);
procedure DuplicRecord(GridOrDSet: TObject; TagToDuplic: integer; DuplicBeforeAfterInsert: boolean);
function GetSQLLine(SQL: TSQLStrings; const KeyWord: string): string;
function GetSQLWhere(SQL: TSQLStrings): string;
function GetSQLTableName(SQL: TSQLStrings): string;
function SetSQLLine(SQL: TSQLStrings; const KeyWord, NewLine: string): boolean;
function SetSQLOrder(SQL: TSQLStrings; const FieldName: string; Desc: boolean): boolean;
function SetSQLWhere(SQL: TSQLStrings; const Condition: string): boolean; overload;
function SetSQLWhere(SQL: TSQLStrings; const FormatCondition: string; Value: Variant): boolean; overload;
function SetSQLWhere(SQL: TSQLStrings; Field: TField): boolean; overload;
function SetSQLWhere(SQL: TSQLStrings; Field: TField; Value: Variant): boolean; overload;
function AddSQLWhereOR(SQL: TSQLStrings; const Condition: string): boolean;
function AddSQLWhereAND(SQL: TSQLStrings; const Condition: string): boolean;
function MakeSQLCond(Field: TField): string; overload;
function MakeSQLCond(Field: TField; Value: Variant): string; overload;
function MakeSQLCond(FormatCondition: string; Value: Variant): string; overload;
function MakeSQLCondOR(const Params: array of string): string;
function MakeSQLCondAND(const Params: array of string): string;
function MakeSQLCondIsNull(Field: TField): string; overload;
function MakeSQLCondIsNull(Field: TField; Value: Variant): string; overload;
function MakeSQLCondLike(const FieldName, Text: string; CompareType: TrLikeCompareType): string;
function FieldNameToCaption(Grid: TDBGrid; const FieldName: string): string; overload;
function FieldNameToCaption(Dataset: TDataSet; const FieldName: string): string; overload;
function FieldListToCaptionList(Grid: TDBGrid; const FieldList, Separator: string): string; overload;
function FieldListToCaptionList(Dataset: TDataSet; const FieldList, Separator: string): string; overload;
function LoadRecordList(CaptionF, IdF: TField; L: TStrings): integer;
procedure GenerateSQLScript(SqlCmd: TSQLStrings; DS: TDataSet; const TableName: string; KeyFieldList, FieldList: TStrings; GenerateInsert, AllRecords: boolean; AddAfterEachRecord: string = '');
procedure GenerateSaveSQLScript(SqlCmd: TSQLStrings; DS: TDataSet; const TableName: string; KeyFieldList, FieldList: TStrings; GenerateInsert, AllRecords: boolean; FileName: string);
function SetFilterString(D: TDataSet; const Filter: string; ShowError: boolean): boolean;
procedure ClearFilter(const GridOrDataSet: TObject);
function GetFilterCond(Field: TField; const Value: string; IsNull: boolean): string;
function FilterByField(Field: TField; FilterJoin: TFilterJoin = fjNone): boolean;
function FilterBySel(const Grid: TDBGrid; FilterJoin: TFilterJoin = fjNone): boolean;
function NegateFilter(const GridOrDataSet: TObject): boolean;

Types

TSQLStrings = TStrings;
TGetFldDef = (...);
TGetFldDefs = set of TGetFldDef;
TFilterJoin = (...);
TrLikeCompareType = (...);

Constants

sfSimpleFld: Set of TFieldType = ([ftString, ftWideString, ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime, ftAutoInc, ftLargeint,ftTimeStamp,ftLongWord,ftShortint, ftByte, ftExtended,ftSingle]);
sfApostrFld: Set of TFieldType = ([ftString, ftWideString, ftDate, ftTime, ftDateTime, ftTimeStamp, ftMemo, ftFmtMemo, ftWideMemo, ftBlob]);

Description

Functions and Procedures

function GetDataSet(GridOrDSet: TObject): TDataSet;
 
function GetDSStateStr(GridOrDSet: TObject): string;
 
procedure AssignGridProps(Source, Dest: TDBGrid);
 
function IsEditing(GridOrDSet: TObject): boolean;
 
function IsDataField(Fld: TField): boolean;
 
function IsSimpleField(Fld: TField): boolean;
 
function IsApostrField(Fld: TField): boolean;
 
function IsMemoField(Fld: TField): boolean;
 
function IsGraphicField(Fld: TField): boolean;
 
function IsDateTimeField(Fld: TField): boolean;
 
function IsDateField(Fld: TField): boolean;
 
function IsTimeField(Fld: TField): boolean;
 
function GetFldDefs(GetLabels, VisibleFieldOnly, SimpleField, MemoField, AllField, DataFieldOnly: boolean): TGetFldDefs;
 
function GetFldList(GridOrDSet: TObject; List: TStrings; FldsDef: TGetFldDefs): integer;
 
function GetFldListValues(Dataset: TDataSet; const FldList: string; const ListSeparator: string = ';'; const ConstMarks: string = '"'): string;
 
function ShowRecordCount(GridOrDSet: TObject): boolean;
 
function LocateRecord(F: TField; Value: Variant; CaseSensitive: boolean = false): boolean;
 
function LocateRecordText(F: TField; const Value: string): boolean;
 
function FillTextMask(const Mask: string; Dataset: TDataSet; const MaskStrStart: string = '<<'; const MaskStrStop: string = '>>'): string;
 
procedure AddRecordEx(G: TDBGrid; Insert: boolean = false);
 
procedure DuplicRecord(GridOrDSet: TObject; TagToDuplic: integer; DuplicBeforeAfterInsert: boolean);
 
function GetSQLLine(SQL: TSQLStrings; const KeyWord: string): string;
 
function GetSQLWhere(SQL: TSQLStrings): string;
 
function GetSQLTableName(SQL: TSQLStrings): string;
 
function SetSQLLine(SQL: TSQLStrings; const KeyWord, NewLine: string): boolean;
 
function SetSQLOrder(SQL: TSQLStrings; const FieldName: string; Desc: boolean): boolean;
 
function SetSQLWhere(SQL: TSQLStrings; const Condition: string): boolean; overload;
 
function SetSQLWhere(SQL: TSQLStrings; const FormatCondition: string; Value: Variant): boolean; overload;
 
function SetSQLWhere(SQL: TSQLStrings; Field: TField): boolean; overload;
 
function SetSQLWhere(SQL: TSQLStrings; Field: TField; Value: Variant): boolean; overload;
 
function AddSQLWhereOR(SQL: TSQLStrings; const Condition: string): boolean;
 
function AddSQLWhereAND(SQL: TSQLStrings; const Condition: string): boolean;
 
function MakeSQLCond(Field: TField): string; overload;
 
function MakeSQLCond(Field: TField; Value: Variant): string; overload;
 
function MakeSQLCond(FormatCondition: string; Value: Variant): string; overload;
 
function MakeSQLCondOR(const Params: array of string): string;
 
function MakeSQLCondAND(const Params: array of string): string;
 
function MakeSQLCondIsNull(Field: TField): string; overload;
 
function MakeSQLCondIsNull(Field: TField; Value: Variant): string; overload;
 
function MakeSQLCondLike(const FieldName, Text: string; CompareType: TrLikeCompareType): string;
 
function FieldNameToCaption(Grid: TDBGrid; const FieldName: string): string; overload;
 
function FieldNameToCaption(Dataset: TDataSet; const FieldName: string): string; overload;
 
function FieldListToCaptionList(Grid: TDBGrid; const FieldList, Separator: string): string; overload;
 
function FieldListToCaptionList(Dataset: TDataSet; const FieldList, Separator: string): string; overload;
 
function LoadRecordList(CaptionF, IdF: TField; L: TStrings): integer;
 
procedure GenerateSQLScript(SqlCmd: TSQLStrings; DS: TDataSet; const TableName: string; KeyFieldList, FieldList: TStrings; GenerateInsert, AllRecords: boolean; AddAfterEachRecord: string = '');
 
procedure GenerateSaveSQLScript(SqlCmd: TSQLStrings; DS: TDataSet; const TableName: string; KeyFieldList, FieldList: TStrings; GenerateInsert, AllRecords: boolean; FileName: string);
 
function SetFilterString(D: TDataSet; const Filter: string; ShowError: boolean): boolean;

Dataset Filter tools (moved from rDBFilter)

procedure ClearFilter(const GridOrDataSet: TObject);
 
function GetFilterCond(Field: TField; const Value: string; IsNull: boolean): string;
 
function FilterByField(Field: TField; FilterJoin: TFilterJoin = fjNone): boolean;
 
function FilterBySel(const Grid: TDBGrid; FilterJoin: TFilterJoin = fjNone): boolean;
 
function NegateFilter(const GridOrDataSet: TObject): boolean;
 

Types

TSQLStrings = TStrings;
 
TGetFldDef = (...);
 
Values
  • fdGetLabels:  
  • fdVisibleFieldOnly:  
  • fdSimpleField:  
  • fdMemoField:  
  • fdAllField:  
  • fdDataFieldOnly:  
TGetFldDefs = set of TGetFldDef;
 
TFilterJoin = (...);
 
Values
  • fjNone:  
  • fjAnd:  
  • fjOr:  
TrLikeCompareType = (...);
 
Values
  • lcAnyPos:  
  • lcBegin:  
  • lcSame:  
  • lcAllWords:  
  • lcAnyWords:  

Constants

sfSimpleFld: Set of TFieldType = ([ftString, ftWideString, ftSmallint, ftInteger, ftWord, ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime, ftAutoInc, ftLargeint,ftTimeStamp,ftLongWord,ftShortint, ftByte, ftExtended,ftSingle]);
 
sfApostrFld: Set of TFieldType = ([ftString, ftWideString, ftDate, ftTime, ftDateTime, ftTimeStamp, ftMemo, ftFmtMemo, ftWideMemo, ftBlob]);
 

Author

Created

Dec 2011

Last Modified

Sep 2015


Generated by PasDoc 0.13.0 on 2016-02-19 08:14:10