Class TSQLiteDatabase

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSQLiteDatabase = class(TObject)

Description

Class for handling SQLite database

Hierarchy

Overview

Methods

Public constructor Create(const FileName: AnsiString);
Public destructor Destroy; override;
Public procedure ExecSQL(const SQL: Ansistring);
Public function GetTable(const SQL: Ansistring; PrepareOnly: Boolean = false): TSQLiteTable;
Public function GetTableValue(const SQL: Ansistring): int64;
Public function GetTableString(const SQL: Ansistring): AnsiString;
Public procedure GetTableStrings(const SQL: Ansistring; const Value: TStrings);
Public function InTransaction: Boolean;
Public procedure Start(const name:AnsiString; const param: AnsiString = '');
Public procedure Commit(const name:AnsiString);
Public procedure Rollback(const name:AnsiString);
Public function LastInsertRowID: int64;
Public function LastChangedRows: int64;
Public procedure SetTimeout(Value: integer);
Public function Version: AnsiString;
Public procedure AddCustomCollate(name: AnsiString; xCompare: TCollateXCompare);
Public Procedure AddSystemCollate;
Public procedure ParamsClear;
Public procedure AddParamInt(const name: AnsiString; value: int64);
Public procedure AddParamFloat(const name: AnsiString; value: double);
Public procedure AddParamText(const name: AnsiString; const value: AnsiString);
Public procedure AddParamNull(const name: AnsiString);

Properties

Public property DB: TSQLiteDB read fDB;
Published property OnQuery: THookQuery read FOnQuery write FOnQuery;

Description

Methods

Public constructor Create(const FileName: AnsiString);

Class constructor. Pass filename of database. If databas not exists, then new one is created. If you pass empty string as filename, then temporary database is created. If you pass ':memory:' as filename, then temporary database in memory is created.

Public destructor Destroy; override;

Class descructor. Call Free instead.

Public procedure ExecSQL(const SQL: Ansistring);

Run SQL command without result. You can call before functions AddParam* for set query parameters.

Public function GetTable(const SQL: Ansistring; PrepareOnly: Boolean = false): TSQLiteTable;

Run SQL command with result. You can call before functions AddParam* for set query parameters. If you set PerpareOnly, then query is just prepared but first row is not fetched!

Public function GetTableValue(const SQL: Ansistring): int64;

Run SQL command and number from first field in first row is returned. You can call before functions AddParam* for set query parameters.

Public function GetTableString(const SQL: Ansistring): AnsiString;

Run SQL command and value from first field in first row is returned. You can call before functions AddParam* for set query parameters.

Public procedure GetTableStrings(const SQL: Ansistring; const Value: TStrings);

Run SQL command and values from first field in each row is filled to stringlist. You can call before functions AddParam* for set query parameters.

Public function InTransaction: Boolean;

Return True if database is in transaction state.

Public procedure Start(const name:AnsiString; const param: AnsiString = '');

Start transaction. You can modify transaction type by Param parameter. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public procedure Commit(const name:AnsiString);

Commit transaction. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public procedure Rollback(const name:AnsiString);

Rollback transaction. If you use non-empty Name parameter, then savepoint is used. Savepoint is named and can be nested.

Public function LastInsertRowID: int64;

Get ROWID of last inserted row.

Public function LastChangedRows: int64;

Return number of modified rows by last query.

Public procedure SetTimeout(Value: integer);

Set wait timeout. if database is locked, then it wait this timeout. If database is not released within this timeout, then error is returned.

Public function Version: AnsiString;

Return SQLite engine version.

Public procedure AddCustomCollate(name: AnsiString; xCompare: TCollateXCompare);

Add custom sorting procedure as new Collate.

Public Procedure AddSystemCollate;

Add collate named SYSTEM for correct data sorting by user's locale

Public procedure ParamsClear;

Clear all query parameters.

Public procedure AddParamInt(const name: AnsiString; value: int64);

Add named query parameter of integer type.

Public procedure AddParamFloat(const name: AnsiString; value: double);

Add named query parameter of floating-point type.

Public procedure AddParamText(const name: AnsiString; const value: AnsiString);

Add named query parameter of string or binary type.

Public procedure AddParamNull(const name: AnsiString);

Add named query parameter with null value.

Properties

Public property DB: TSQLiteDB read fDB;

SQLite database handler.

Published property OnQuery: THookQuery read FOnQuery write FOnQuery;

Debug hook for log all called queries.


Generated by PasDoc 0.9.0 on 2009-06-16 13:42:34