CONNECT
Description
Establishes a connection to a database. Optionally, the CONNECT statement can also specify a name for the connection and a user-name/password for authentication.
Syntax
CONNECT TO connect_string
[AS connection_name]
[USER user_name]
[USING password]
connect_string::
{ DEFAULT
| db_name
| port@host_name:db_name }
Arguments
Arguments to CONNECT must either be string literals enclosed in quotation marks or character-string host variables.
connect_string
The string that specifies the database to connect to. If the CONNECT statement specifies DEFAULT, FairCom DB SQL tries to connect to the environment-defined database, if any. (How you define the default database varies between operating systems. On Unix, the value of the DB_NAME environment variable specifies the default connect string.)
The connect string can be a simple database name or a complete connect string. A complete connect string has the following components:
port |
The port number, default 6597 |
host_name |
Name or IP address of the system where the database resides. |
db_name |
Name of the database. |
connection_name
The name for the connection for use in DISCONNECT and SET CONNECTION statements. If the CONNECT statement omits a connection name, the default is the name of the database. Connection names must be unique.
user_name
User name for authentication of the connection. FairCom DB SQL verifies the user name against a corresponding password before it connects to the database. If omitted, the default value depends on the environment. (On UNIX, the value of the DH_USER environment variable specifies the default user name. If DH_USER is not set, the value of the USER environment variable specifies the default user name.)
password
Password for authentication of the connection. FairCom DB SQL verifies the password against a corresponding user name before it connects to the database. If omitted, the default value depends on the environment.
(On Unix, the value of the DH_PASSWD environment variable specifies the default password.)
Notes
Authorization
None.
Examples
The following examples illustrate the CONNECT statement:
CONNECT TO 'salesdb' AS 'sales_conn';
CONNECT TO '6597@localhost:custdb' AS 'cust_conn';
CONNECT TO '6597@testbox:custdb' AS 'cust_conn';
CONNECT TO DEFAULT;
SQL Compliance |
SQL-92 |
Environment |
Embedded SQL and interactive |
Related Statements |
DISCONNECT, SET CONNECTION |