Precedence of Parameters

 

The database connection can be set in the database.cfg file and then overridden by the CONNECT TO statement completely or partially. Since all the clauses of the CONNECT TO statement and the parameters of the database connection in the configuration file are optional, there may be a set of cases when some parameters are missing and some are set twice.

 

Generally speaking CONNECT TO is of the higher precedence than database.cfg, and the latter overrides the environment variables settings and flags. The -d flag and environment variables are of the lowest precedence in order to enable the usage of different database drivers within an application.

 

The following table shows the result of some parameters being set twice or not being set at all.

 

Parameter

Set in CONNECT TO

Set in database.cfg

Used Value

driver

CONNECT TO

CONNECT TO

database.cfg

no

-d flag for program launching is used. If it is not passed - LYCIA_DB_DRIVER value will be used.

source

CONNECT TO

CONNECT TO

database.cfg

The dbname value is treated as source.

username

CONNECT TO

CONNECT TO

database.cfg

DB-specific settings are used, if they are not set then program tries to connect with no username

password

CONNECT TO

CONNECT TO

database.cfg

Legacy settings are used, if they are not set then program tries to connect with no password

 

Here is an example with not all optional parameters present:

 

stores {

driver = "oracle"

username = "john"

password = "123456"

}

ifx_db {

source = "stores@ixserv"

}

 

If we use the CONNECT TO without optional clauses, we will get: