Sign in Join
FPDoc Onlineexperiment

SQLDB unit

A set of classes for connecting to SQL databases and running SQL commands on them.

The SQLDB unit defines four main classes to handle data in SQL based databases.

  1. TSQLConnection represents the connection to the database. Here, properties pertaining to the connection (machine, database, user password) must be set. This is an abstract class, which should not be used directly. Per database type (mysql, firebird, postgres, oracle, sqlite) a descendent should be made and used.
  2. TSQLQuery is a TDataset descendent which can be used to view and manipulate the result of an SQL select query. It can also be used to execute all kinds of SQL statements.
  3. TSQLTransaction represents the transaction in which an SQL command is running. SQLDB supports multiple simultaneous transactions in a database connection. For databases that do not support this functionality natively, it is simulated by maintaining multiple connections to the database.
  4. TSQLScript can be used when many SQL commands must be executed on a database, for example when creating a database.

There is also a unified way to retrieve schema information, and a registration for connector types. More information on how to use these components can be found in UsingSQLDB.

Classes and records

ESQLDatabaseErrorclassSQL database error class.
TConnectionDefclassConnection type definition class.
TCustomSQLQueryclassCustom Class to handle SQL commands (with or without result set).
TCustomSQLStatementclassObject to execute SQL statements without result set.
TServerIndexDefsclassSQLDB specific descendant of the TIndexDefs.
TSQLConnectionclassAn abstract class representing a connection to a SQL Database.
TSQLConnectorclassUniversal connection component.
TSQLCursorclassInternal object representing a database result set.
TSQLDBFieldDefclassTFieldDef descendant with room to store engine-specific data.
TSQLDBFieldDefsclassTFieldDefs descendant with room to store engine-specific data.
TSQLDBParamclassTParam descendent used in SQLDB.
TSQLDBParamsclassTParams descendant with room to store engine-specific data.
TSQLHandleclassInternal object representing a database internal handle.
TSQLQueryclassClass to handle SQL commands (with or without result set).
TSQLScriptclassComponent to execute various SQL statements.
TSQLSequenceclassSupport for applying sequences to fields.
TSQLStatementclassClass to execute non-select SQL statements.
TSQLStatementInforecordRecord to describe a SQL statement.
TSQLTransactionclassTransaction in which a TSQLQuery is handled.

Procedures and functions

GetConnectionDeffunctionSearch for a connection definition by name.
GetConnectionListprocedureReturn a list of connection definition names.
RegisterConnectionprocedureRegister a new connection type for use in the universal connector.
UnRegisterConnectionprocedureUnregister a registered connection type.

Types

TCommitRollbackActionenumerationTransaction actions (unused).
TConnectionDefClasstypeClass of TConnectionDef.
TConnInfoTypeenumerationConnection information to be retrieved.
TConnOptionenumerationConnection options.
TConnOptionssetSet of TConnOption.
TDBEventTypetypeType of database event.
TDBEventTypestypeSet of database event types.
TDBLogNotifyEventprocedure typeEvent handler prototype for handling events.
TLibraryLoadFunctionprocedure typeLibrary loading function prototype.
TLibraryUnLoadFunctionprocedure typeLibrary unloading function prototype.
TQuoteCharstypeType to describe quote characters.
TRowsCounttypeA type to contain a result row count.
TSchemaTypetypeSchema type to retrieve.
TSQLConnectionClasstypeClass of TSQLConnection type.
TSQLConnectionOptionenumerationConnection handling options.
TSQLConnectionOptionssetSet of TSQLConnectionOption.
TSQLQueryOptionenumerationSQL Query options.
TSQLQueryOptionssetSet of TSQLQueryOption.
TSQLSequenceApplyEventenumerationWhen to fetch a new sequence number.
TSQLTransactionOptionenumerationTransaction control options.
TSQLTransactionOptionssetSet of TSQLTransactionOption.
TStatementTypetypeType describing the kind of SQL statement.

Constants

DefaultMacroCharconstantDefault character to use as a macro delimiter.
DefaultSQLFormatSettingsconstantDefault settings to be used in SQL.
detActualSQLconstantAlias for sqltypes.detActualSQL.
detCommitconstantAlias for sqltypes.detCommit.
detCustomconstantAlias for sqltypes.detCustom.
detExecuteconstantAlias for sqltypes.detExecute.
detFetchconstantAlias for sqltypes.detFetch.
detParamValueconstantAlias for sqltypes.detParamValue.
detPrepareconstantAlias for sqltypes.detPrepare.
detRollBackconstantAlias for sqltypes.detRollBack.
DoubleQuotesconstantDouble quote delimiters.
LogAllEventsconstantConstant that can be used to select all events.
LogAllEventsExtraconstantAll possible event types that must be reported.
SingleQuotesconstantSingle quote delimiters.
StatementTokensconstantArray of tokens used to determine the statement type.
stColumnsconstantAlias for sqltypes.stColumns.
stCommitconstantAlias for sqltypes.stCommit.
stDDLconstantAlias for sqltypes.stDDL.
stDeleteconstantAlias for sqltypes.stDelete.
stExecProcedureconstantAlias for sqltypes.stExecProcedure.
stGetSegmentconstantAlias for sqltypes.stGetSegment.
stIndexesconstantAlias for sqltypes.stIndexes.
stInsertconstantAlias for sqltypes.stInsert.
stNoSchemaconstantAlias for sqltypes.stUnknown.
stPackagesconstantAlias for sqltypes.stPackages.
stProcedureParamsconstantAlias for sqltypes.stProcedureParams.
stProceduresconstantAlias for sqltypes.stProcedures.
stPutSegmentconstantAlias for sqltypes.stPutSegment.
stRollbackconstantAlias for sqltypes.stRollback.
stSchemataconstantAlias for sqlTypes.stSchemata.
stSelectconstantAlias for sqltypes.stSelect.
stSelectForUpdconstantAlias for sqltypes.stSelectForUpd.
stSequencesconstantAlias for sqltypes.stSequences.
stStartTransconstantAlias for sqltypes.stStartTrans.
stSysTablesconstantAlias for sqltypes.stSysTables.
stTablesconstantAlias for sqltypes.stTables.
stUnknownconstantAlias for sqltypes.stUnknown.
stUpdateconstantAlias for sqltypes.stUpdate.
TSchemaObjectNamesconstantNames of the various types of objects.

Variables

GlobalDBLogHookvariableGlobal logging hook.

Topics

RetrievingSchemaInformationtopicRetrieving Schema Information.
UniversalConnectorstopicUsing the universal TSQLConnector type.
UpdateSQLstopicAutomatic generation of update SQL statements.
UsingParamstopicUsing parameters.
UsingSQLDBtopicUsing SQLDB to access databases.

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.