Create a dynamic connection string.

It is possible to select the connection to the database within the code using a dynamically created connect string… take the following code as an example for Oracle:

DEFINE username VARCHAR(255)
DEFINE passwd VARCHAR(255)
DEFINE server VARCHAR(255)
DEFINE connectStr VARCHAR(255)
LET server = dbserver --this is the name of your database server
LET connectStr = username CLIPPED,"/",passwd CLIPPED, "@",server CLIPPED
## the following line switches to the username and password specified..
## .. by forming the command 'DATABASE username/password@server'
DATABASE connectStr

You can use a full connect string (eg. user/password@server) with the DATABASE keyword allowing you to dynamically switch database users.