CONNECT TO statement
You can use a host variable to represent the database name you want your
application to connect to, for example:
exec sql connect to :dbase;
If a host variable is specified:
- It must be a character or a character varying variable.
- It must be preceded by a colon and must not be followed by an indicator
variable.
- The server-name that is contained within the host variable must be left-justified.
- If the length of the server name is less than the length of the fixed-length
character host variable, it must be padded on the right with blanks.
dcl dbase char (10);
dbase = 'SAMPLE'; /* blanks are padded automatically */
exec sql connect to :dbase;
- If a varying character host variable is used, you may receive the following
warning from the compiler. You can ignore this message.
IBM1214I W xxx.x A dummy argument is created for argument
number 6 in entry reference SQLESTRD_API