IDAConnection
Overview
The IDAConnection interface represents an individual connection to a database.
Connections are usually obtained from the TDAConnectionManager component and will be implemented by different classes depending on the database driver you are using.
Connection classes for some drivers implement additional interfaces that expose driver- or database-specific functionality, such as IDAADOConnection, IDAInterbaseConnection or IDAOracleConnection.
Location
- Unit: uDAServerInterfaces.pas
- Ancestry: IDACustomConnection | IDAConnection
BeginTransaction safecall
Starts transaction.
function BeginTransaction: Integer
Close safecall
Closes a physical connection to the database back-end,
procedure Close
CommitTransaction safecall
Commits transaction.
procedure CommitTransaction
Connected
Indicates whether the connection object currently has an active link to the database (true) or not (false). Usually, a Data Abstract connection connects to the database when it is created, and is not closed until discarded and eventually removed from the connection pool. However, you can use the Open and Close methods to manually connect or disconnect from the database, if needed.
property Connected: Boolean read write
ConnectionPool
Provides access to the IDAConnectionPool.
property ConnectionPool: IDAConnectionPool read write
ConnectionString
Sets the database connection string that was used to open this connection. The exact content of this string depends on the driver and database you are using, but it will usually contain information such as the database name, user id and password, as well as additional connection parameters. Please refer to the reference for the specific driver for more details.
property ConnectionString: string read write
ConnectionType
Holds the connection type.
property ConnectionType: string read
GetConnected safecall
Returns connection state.
function GetConnected: Boolean
GetForeignKeys safecall
Fills ForeignKeys with actual foreign keys.
procedure GetForeignKeys(out ForeignKeys: TDADriverForeignKeyCollection)
Parameters:
- ForeignKeys: collection that will be filled.
GetLastAutoInc safecall
Returns last autoinc value.
function GetLastAutoInc(const GeneratorName: string): Integer
Parameters:
- GeneratorName: Specified generator name.
GetLastAutoIncValue safecall
Returns last autoinc value.
function GetLastAutoIncValue(const GeneratorName: string): Variant
Parameters:
- GeneratorName: Specified generator name.
GetPassword safecall
Returns the password.
function GetPassword: string
GetQueryBuilder safecall (declared in IDACustomConnection)
Creates an instance of the TDAQueryBuilder.
function GetQueryBuilder: TDAQueryBuilder
GetQueryFields safecall
Returns the fields of a specified SQL.
procedure GetQueryFields(const aSQL: string; aParamsIfNeeded: TDAParamCollection; out Fields: TDAFieldCollection)
Parameters:
- aSQL: given SQL
- aParamsIfNeeded: optional parameters
- Fields: fields of SQL
GetQuoteChars safecall
Returns quote symbols as an array.
function GetQuoteChars: TDAQuoteCharArray
GetSPSelectSyntax safecall
Returns select syntax for stored procedure.
function GetSPSelectSyntax(HasArguments: Boolean): string
Parameters:
- HasArguments: parameters are present or not
GetStoredProcedureNames safecall
Returns the list of stored procedures names.
procedure GetStoredProcedureNames(out List: IROStrings)
Parameters:
- List: list of stored procedures names
GetStoredProcedureParams safecall
Retrieves the stored procedure params.
procedure GetStoredProcedureParams(const aStoredProcedureName: string; out Params: TDAParamCollection)
Parameters:
- aStoredProcedureName: stored procedure's name
- Params: stored procedure params.
GetTableFields safecall (declared in IDACustomConnection)
Returns the fields of a specified table.
procedure GetTableFields(const aTableName: string; out Fields: TDAFieldCollection)
Parameters:
- aTableName: Specified data table name
- Fields: Output collection of data table fields
GetTableNames safecall
Returns the list of tables names.
procedure GetTableNames(out List: IROStrings)
Parameters:
- List: list of tables names.
GetUserID safecall
Returns the user ID.
function GetUserID: string
GetViewFields safecall
Returns the fields of a specified view.
procedure GetViewFields(const aViewName: string; out Fields: TDAFieldCollection)
Parameters:
- aViewName: view's name
- Fields: fields of a specified view.
GetViewNames safecall
Returns the list of view names.
procedure GetViewNames(out List: IROStrings)
Parameters:
- List: list of view names.
GetWhereBuilder safecall
Creates an instance of the TDASQLWhereBuilder.
function GetWhereBuilder: TDASQLWhereBuilder
IdentifierNeedsQuoting safecall (declared in IDACustomConnection)
Checks if identifier need to be quoted
function IdentifierNeedsQuoting(const iIdentifier: string): Boolean
Parameters:
- iIdentifier: identifier.
InTransaction
Indicates whether the connection is currently inside a transaction (true) or not (false). When inside a transaction, all changes made to the database are not applied to the physical database right away, but will be held until the transaction is commited. Then and only then will all changes be made permanent. Exact transaction behavior (such as transaction isolation) might also depend on the used database back-end setup and the connection parameters.
property InTransaction: Boolean read
isAlive safecall
Returns True if connection is alive.
function isAlive: Boolean
Name
Returns a human-readable name for the connection. For connections obtained through a TDAConnectionManager component, this will be the name that the connection was defined under in Schema Modeler.
property Name: string read
NewCommand safecall
Returns a new IDASQLCommand implementation that can be used to executing custom command that was previously defined in schema.
function NewCommand(const Text: string; CommandType: TDASQLStatementType; const aCommandName: string): IDASQLCommand
Parameters:
- Text: stored procedure's name or SQL statement (depends on command type)
- CommandType: command type
- aCommandName: command name
NewDataset safecall
Returns a new IDADataset implementation that can be used to retrieve records from the database.
function NewDataset(const SQL: string; const aDatasetName: string): IDADataset
Parameters:
- SQL: SQL statement
- aDatasetName: Dataset's name
OnAfterExecuteCommand
Fires right after a command was executed.
property OnAfterExecuteCommand: TDAAfterExecuteCommandEvent read write
delegate: procedure OnAfterExecuteCommand(const Sender: IDASQLCommand; ActualSQL: string; ElapsedMilliseconds: Cardinal)
OnAfterOpenDataset
Fires after dataset was opened
property OnAfterOpenDataset: TDAAfterOpenDatasetEvent read write
delegate: procedure OnAfterOpenDataset(const Sender: IDADataset; ActualSQL: string; ElapsedMilliseconds: Cardinal)
OnBeforeExecuteCommand
Fires just before a command will be executed.
property OnBeforeExecuteCommand: TDABeforeExecuteCommandEvent read write
delegate: procedure OnBeforeExecuteCommand(const Sender: IDASQLCommand)
OnBeforeOpenDataset
Fires before dataset was opened
property OnBeforeOpenDataset: TDABeforeOpenDatasetEvent read write
delegate: procedure OnBeforeOpenDataset(const Sender: IDADataset)
OnExecuteCommandError
Fires if error was present during execution of command.
property OnExecuteCommandError: TDAExecuteCommandErrorEvent read write
delegate: procedure OnExecuteCommandError(const Sender: IDASQLCommand; ActualSQL: string; Error: Exception)
OnOpenDatasetError
Fired if error was occured duting opening of dataset
property OnOpenDatasetError: TDAOpenDatasetErrorEvent read write
delegate: procedure OnOpenDatasetError(const Sender: IDADataset; ActualSQL: string; Error: Exception)
Open safecall
Establishes a physical connection to the database back-end, using the specified ConnectionString.
procedure Open(const aUserID: string; const aPassword: string)
Parameters:
- aUserID: username
- aPassword: password
Password
Defines the Password that was or will be used to open this connection. This value is usually obtained from the connection string.
property Password: string read write
QuoteFieldName safecall (declared in IDACustomConnection)
Quotes field name.
function QuoteFieldName(const aTableName: string; const aFieldName: string): string
Parameters:
- aTableName: table name.
- aFieldName: field name.
QuoteFieldNameIfNeeded safecall (declared in IDACustomConnection)
Quotes field name if is required.
function QuoteFieldNameIfNeeded(const aTableName: string; const aFieldName: string): string
Parameters:
- aTableName: table name.
- aFieldName: field name.
QuoteIdentifier safecall (declared in IDACustomConnection)
Quotes identifier.
function QuoteIdentifier(const iIdentifier: string): string
Parameters:
- iIdentifier: identifier.
QuoteIdentifierIfNeeded safecall (declared in IDACustomConnection)
Quotes identifier if is required.
function QuoteIdentifierIfNeeded(const iIdentifier: string): string
Parameters:
- iIdentifier: identifier.
RollbackTransaction safecall
Discards a transaction that was started with a prior call to BeginTransaction. All changes made in the context of the transaction will be be discarded and not applied to the physical database. To persist the changes made, instead of discarding them, call CommitTransaction instead.
procedure RollbackTransaction
SetConnected safecall
Opens or closes a physical connection to the database back-end,
procedure SetConnected(Value: Boolean)
Parameters:
- Value: state
SetPassword safecall
Sets the password.
procedure SetPassword(const Value: string)
Parameters:
- Value: password
SetUserID safecall
Sets the user ID.
procedure SetUserID(const Value: string)
Parameters:
- Value: user ID
UseMacroProcessor
Specifies an usage of macro processor.
property UseMacroProcessor: Boolean read write
UserID
Holds the User ID that was or will be used to open this connection. This value is usually obtained from the connection string.
property UserID: string read write
Connected
Indicates whether the connection object currently has an active link to the database (true) or not (false). Usually, a Data Abstract connection connects to the database when it is created, and is not closed until discarded and eventually removed from the connection pool. However, you can use the Open and Close methods to manually connect or disconnect from the database, if needed.
property Connected: Boolean read write
ConnectionPool
Provides access to the IDAConnectionPool.
property ConnectionPool: IDAConnectionPool read write
ConnectionString
Sets the database connection string that was used to open this connection. The exact content of this string depends on the driver and database you are using, but it will usually contain information such as the database name, user id and password, as well as additional connection parameters. Please refer to the reference for the specific driver for more details.
property ConnectionString: string read write
ConnectionType
Holds the connection type.
property ConnectionType: string read
InTransaction
Indicates whether the connection is currently inside a transaction (true) or not (false). When inside a transaction, all changes made to the database are not applied to the physical database right away, but will be held until the transaction is commited. Then and only then will all changes be made permanent. Exact transaction behavior (such as transaction isolation) might also depend on the used database back-end setup and the connection parameters.
property InTransaction: Boolean read
Name
Returns a human-readable name for the connection. For connections obtained through a TDAConnectionManager component, this will be the name that the connection was defined under in Schema Modeler.
property Name: string read
Password
Defines the Password that was or will be used to open this connection. This value is usually obtained from the connection string.
property Password: string read write
UseMacroProcessor
Specifies an usage of macro processor.
property UseMacroProcessor: Boolean read write
UserID
Holds the User ID that was or will be used to open this connection. This value is usually obtained from the connection string.
property UserID: string read write
BeginTransaction safecall
Starts transaction.
function BeginTransaction: Integer
Close safecall
Closes a physical connection to the database back-end,
procedure Close
CommitTransaction safecall
Commits transaction.
procedure CommitTransaction
GetConnected safecall
Returns connection state.
function GetConnected: Boolean
GetForeignKeys safecall
Fills ForeignKeys with actual foreign keys.
procedure GetForeignKeys(out ForeignKeys: TDADriverForeignKeyCollection)
Parameters:
- ForeignKeys: collection that will be filled.
GetLastAutoInc safecall
Returns last autoinc value.
function GetLastAutoInc(const GeneratorName: string): Integer
Parameters:
- GeneratorName: Specified generator name.
GetLastAutoIncValue safecall
Returns last autoinc value.
function GetLastAutoIncValue(const GeneratorName: string): Variant
Parameters:
- GeneratorName: Specified generator name.
GetPassword safecall
Returns the password.
function GetPassword: string
GetQueryBuilder safecall (declared in IDACustomConnection)
Creates an instance of the TDAQueryBuilder.
function GetQueryBuilder: TDAQueryBuilder
GetQueryFields safecall
Returns the fields of a specified SQL.
procedure GetQueryFields(const aSQL: string; aParamsIfNeeded: TDAParamCollection; out Fields: TDAFieldCollection)
Parameters:
- aSQL: given SQL
- aParamsIfNeeded: optional parameters
- Fields: fields of SQL
GetQuoteChars safecall
Returns quote symbols as an array.
function GetQuoteChars: TDAQuoteCharArray
GetSPSelectSyntax safecall
Returns select syntax for stored procedure.
function GetSPSelectSyntax(HasArguments: Boolean): string
Parameters:
- HasArguments: parameters are present or not
GetStoredProcedureNames safecall
Returns the list of stored procedures names.
procedure GetStoredProcedureNames(out List: IROStrings)
Parameters:
- List: list of stored procedures names
GetStoredProcedureParams safecall
Retrieves the stored procedure params.
procedure GetStoredProcedureParams(const aStoredProcedureName: string; out Params: TDAParamCollection)
Parameters:
- aStoredProcedureName: stored procedure's name
- Params: stored procedure params.
GetTableFields safecall (declared in IDACustomConnection)
Returns the fields of a specified table.
procedure GetTableFields(const aTableName: string; out Fields: TDAFieldCollection)
Parameters:
- aTableName: Specified data table name
- Fields: Output collection of data table fields
GetTableNames safecall
Returns the list of tables names.
procedure GetTableNames(out List: IROStrings)
Parameters:
- List: list of tables names.
GetUserID safecall
Returns the user ID.
function GetUserID: string
GetViewFields safecall
Returns the fields of a specified view.
procedure GetViewFields(const aViewName: string; out Fields: TDAFieldCollection)
Parameters:
- aViewName: view's name
- Fields: fields of a specified view.
GetViewNames safecall
Returns the list of view names.
procedure GetViewNames(out List: IROStrings)
Parameters:
- List: list of view names.
GetWhereBuilder safecall
Creates an instance of the TDASQLWhereBuilder.
function GetWhereBuilder: TDASQLWhereBuilder
IdentifierNeedsQuoting safecall (declared in IDACustomConnection)
Checks if identifier need to be quoted
function IdentifierNeedsQuoting(const iIdentifier: string): Boolean
Parameters:
- iIdentifier: identifier.
isAlive safecall
Returns True if connection is alive.
function isAlive: Boolean
NewCommand safecall
Returns a new IDASQLCommand implementation that can be used to executing custom command that was previously defined in schema.
function NewCommand(const Text: string; CommandType: TDASQLStatementType; const aCommandName: string): IDASQLCommand
Parameters:
- Text: stored procedure's name or SQL statement (depends on command type)
- CommandType: command type
- aCommandName: command name
NewDataset safecall
Returns a new IDADataset implementation that can be used to retrieve records from the database.
function NewDataset(const SQL: string; const aDatasetName: string): IDADataset
Parameters:
- SQL: SQL statement
- aDatasetName: Dataset's name
Open safecall
Establishes a physical connection to the database back-end, using the specified ConnectionString.
procedure Open(const aUserID: string; const aPassword: string)
Parameters:
- aUserID: username
- aPassword: password
QuoteFieldName safecall (declared in IDACustomConnection)
Quotes field name.
function QuoteFieldName(const aTableName: string; const aFieldName: string): string
Parameters:
- aTableName: table name.
- aFieldName: field name.
QuoteFieldNameIfNeeded safecall (declared in IDACustomConnection)
Quotes field name if is required.
function QuoteFieldNameIfNeeded(const aTableName: string; const aFieldName: string): string
Parameters:
- aTableName: table name.
- aFieldName: field name.
QuoteIdentifier safecall (declared in IDACustomConnection)
Quotes identifier.
function QuoteIdentifier(const iIdentifier: string): string
Parameters:
- iIdentifier: identifier.
QuoteIdentifierIfNeeded safecall (declared in IDACustomConnection)
Quotes identifier if is required.
function QuoteIdentifierIfNeeded(const iIdentifier: string): string
Parameters:
- iIdentifier: identifier.
RollbackTransaction safecall
Discards a transaction that was started with a prior call to BeginTransaction. All changes made in the context of the transaction will be be discarded and not applied to the physical database. To persist the changes made, instead of discarding them, call CommitTransaction instead.
procedure RollbackTransaction
SetConnected safecall
Opens or closes a physical connection to the database back-end,
procedure SetConnected(Value: Boolean)
Parameters:
- Value: state
SetPassword safecall
Sets the password.
procedure SetPassword(const Value: string)
Parameters:
- Value: password
SetUserID safecall
Sets the user ID.
procedure SetUserID(const Value: string)
Parameters:
- Value: user ID
OnAfterExecuteCommand
Fires right after a command was executed.
property OnAfterExecuteCommand: TDAAfterExecuteCommandEvent read write
delegate: procedure OnAfterExecuteCommand(const Sender: IDASQLCommand; ActualSQL: string; ElapsedMilliseconds: Cardinal)
OnAfterOpenDataset
Fires after dataset was opened
property OnAfterOpenDataset: TDAAfterOpenDatasetEvent read write
delegate: procedure OnAfterOpenDataset(const Sender: IDADataset; ActualSQL: string; ElapsedMilliseconds: Cardinal)
OnBeforeExecuteCommand
Fires just before a command will be executed.
property OnBeforeExecuteCommand: TDABeforeExecuteCommandEvent read write
delegate: procedure OnBeforeExecuteCommand(const Sender: IDASQLCommand)
OnBeforeOpenDataset
Fires before dataset was opened
property OnBeforeOpenDataset: TDABeforeOpenDatasetEvent read write
delegate: procedure OnBeforeOpenDataset(const Sender: IDADataset)
OnExecuteCommandError
Fires if error was present during execution of command.
property OnExecuteCommandError: TDAExecuteCommandErrorEvent read write
delegate: procedure OnExecuteCommandError(const Sender: IDASQLCommand; ActualSQL: string; Error: Exception)
OnOpenDatasetError
Fired if error was occured duting opening of dataset
property OnOpenDatasetError: TDAOpenDatasetErrorEvent read write
delegate: procedure OnOpenDatasetError(const Sender: IDADataset; ActualSQL: string; Error: Exception)
- TDAConnectionManager component
- IDAADOConnection, IDAInterbaseConnection and IDAOracleConnection interfaces.
- Database Drivers