Indirect database specification method

Genero BDL allows to define database connection parameters in FGLPROFILE, that can be referenced by a single identifier in programs.

Indirect database specification method takes place when the database name used in the DATABASE or CONNECT TO instruction corresponds to a 'dbi.database.dbname.source' entry defined in the FGLPROFILE configuration file. In this case, the dbname database specification is used as a key to read the connection information from the configuration file.

In FGLPROFILE, the entries starting with 'dbi.database' group information defining connection parameters for indirect database specification:

dbi.database.dbname.source   = "value" 
dbi.database.dbname.driver   = "value" 
dbi.database.dbname.username = "value" 
dbi.database.dbname.password = "value"  
-- Warning: Password is not encrypted, do not use in production!

Keep in mind that FGLPROFILE entry names are converted to lower case when loaded by the runtime system. In order to avoid any mistakes, it is recommended to write FGLPROFILE entry names and program database names in lower case.

In the next example, the program specifies the name mydb in the CONNECT TO instruction, referecing the FGLPROFILE dbi.database.mydb.source and dbi.database.mydb.driver entries, to connect to the stores database controlled by a PostgreSQL server running on the localhost, using TCP port 5432:

Program:

MAIN
  DEFINE un, up STRING
  ...
  CONNECT TO "mydb" USER un USING up
  ...
END MAIN

FGLPROFILE:

dbi.database.mydb.source   = "stores@localhost:5432"
dbi.database.mydb.driver   = "dbmpgs"

The indirect database specification technique is a flexible technique to define the database source: The database name in programs is a kind of alias for the real data source defined in an external FGLPROFILE configuration file, where entries can be easily changed on production sites without needing program recompilation.