Precedence of database settings

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, it may turn out that you haven't set some parameters and have set some other ones twice.

Generally speaking, CONNECT TO has 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 so that you could use different database drivers within one application.

This table shows the result of some parameters being set twice or not being set at all:

parameter

CONNECT TO

database.cfg

resulting settings

driver

+

+

CONNECT TO

 

+

-

CONNECT TO

 

-

+

database.cfg

 

-

-

-d flag for program launching is used. If not, LYCIA_DB_DRIVER value is used

source

+

+

CONNECT TO

 

+

-

CONNECT TO

 

-

+

database.cfg

 

-

-

dbname is treated as source

username

+

+

CONNECT TO

 

+

-

CONNECT TO

 

-

+

database.cfg

 

-

-

db-specific settings are used. If not set, then the program will try to connect with no username

password

+

+

CONNECT TO

 

+

-

CONNECT TO

 

-

+

database.cfg

 

-

-

legacy settings are used. If not set, then the program will try to connect with no password

In this example, some optional parameters are omitted:

stores {

driver = "oracle"

username = "john"

password = "123456"

}

ifx_db {

source = "stores@ixserv"

}

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.