UniDAC

Using DB2 data access provider with UniDAC in Delphi

This article provides a brief overview of the DB2 data access provider for UniDAC used to establish a connection to DB2 databases from Delphi and Lazarus. You will find the description of some useful features and how to get started quickly.

Overview

DB2 provider is based on the ODBC provider. It uses DB2 ODBC driver to work with a database. Main features of the DB2 data access provider are:

The full list of the DB2 provider features can be found on the UniDAC features page.

Both Professional and Standard Editions of UniDAC include the DB2 provider. Express Edition of UniDAC does not include the DB2 provider.

Compatibility

To learn about DB2 database server compatibility, refer to the Compatibility section.

Requirements

Applications that use the DB2 provider require the following components to be installed on the client computer:

Deployment

When an application was built without runtime packages (Link with runtime packages set to False in Project Options), you do not need to deploy any BPL files with it. For more information, see Deployment.
Note that UniDAC Trial requires deployment of additional BPL files regardless of Link with runtime packages.

DB2-specific options

TUniConnection

Option name Description
ColumnWiseBinding

If set to True, the option enables Column-Wise Binding mode. The default value is False.

Note: Row-Wise Binding mode is enabled by default. However, some ODBC drivers don't support this mode. In such case, set the ColumnWiseBinding option to True.

ConnectionTimeout The time to wait for a connection to open before raising an exception.
FunctionPath Use the FunctionPath property to change the current function path of the connection to the specified value. You can specify several names separated by comma. This option can be used to call stored procedures from a schema other than that of the current user without having to qualify the objects with the schema name.
Schema Use the Schema property to change the current schema of the connection to the specified schema. This setting offers a convenient way to perform operations on objects in a schema other than that of the current user without having to qualify the objects with the schema name.
Security Gets or sets the security type being used. If set to smSSL, SSL is enabled. The default value is smDisable.
SSLClientKeyStash

Gets or sets the name of the SSL stash (.sth) file used for an SSL connection. The option value is the name of the SSL stash file used for an SSL connection.

Note: When Security is set to SSL, you must specify the SSLClientKeystoredb option along with this option. The SSL stash file stores an encrypted password for the key database file.

SSLClientkeystoredb

Gets or sets the name of the SSL key database file used for an SSL connection. The option value is the name of the SSL key database file used for an SSL connection.

Note: When Security is set to SSL, you must specify the SSLClientKeystash option along with this option.

UseUnicode Enables or disables Unicode support. Affects character data fetched from the server. When set to True, all character data is stored as WideStrings, and TStringField is replaced by TWideStringFiled.

TUniSQL

Option name Description
CommandTimeout The time to wait for a statement to be executed.

TUniQuery, TUniTable, TUniStoredProc

Option name Description
CommandTimeout The time to wait for a statement to be executed.
ExtendedFieldsInfo If True, an additional query is performed to get information about returned fields and tables they belong to. The default value is True.
KeySequence Use the KeySequence property to specify the name of the sequence that will be used to fill in a key field after a new record is inserted or posted to the database.
FetchAll

If True, all records of a query are requested from database server when the dataset is being opened.

If False, records are retrieved when a data-aware component or a program requests it. The default value is False.

SequenceMode

Set the SequenceMode property to specify which method is used internally to generate sequenced field.

The following values are allowed for this property:

smInsert
New record is inserted into the dataset with the first key field populated with a sequenced value. Application may modify this field before posting the record to the database.
smPost
Database server populates the key field with a sequenced value when application posts the record to the database. Any value put into the key field before post will be overwritten.

TUniScript

The TUniScript component has no DB2-specific options.

TUniLoader

The TUniLoader component has no DB2-specific options.

TUniDump

The TUniDump component has no DB2-specific options.

Data Type Mapping

The following table lists the constants for mapping DB2 data types to Delphi data types. See Data Type Mapping for more information.

Constant Description
db2Char Maps CHARACTER to Delphi data types.
db2VarChar Maps VARCHAR to Delphi data types.
db2SmallInt Maps SMALLINT to Delphi data types.
db2Integer Maps INTEGER to Delphi data types.
db2BigInt Maps BIGINT to Delphi data types.
db2Decimal Maps DECIMAL to Delphi data types.
db2Float Maps FLOAT to Delphi data types.
db2Double Maps DOUBLE to Delphi data types.
db2Real Maps REAL to Delphi data types.
db2Numeric Maps NUMERIC to Delphi data types.
db2Date Maps DATE to Delphi data types.
db2Time Maps TIME to Delphi data types.
db2TimeStamp Maps TIMESTAMP to Delphi data types.
db2Binary Maps BINARY to Delphi data types.
db2VarBinary Maps VARBINARY to Delphi data types.
db2Blob Maps BLOB to Delphi data types.
db2Clob Maps CLOB to Delphi data types.
© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback