CONNECT
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Establishes a connection to a database. Optionally, the CONNECT statement
can also specify a name for the connection and a username and
password for authentication.
Syntax
|
Parameters
- connect_string
-
{ DEFAULT |db_name|db_type:T:host_name:port_num:db_name }Note: Arguments toCONNECTmust be either string literals enclosed in quotation marks or character‑string host variables. - connect_string
-
Specifies to which database to connect. If the
CONNECTstatement specifiesDEFAULT, SQL tries to connect to the environment-defined database, if any. The value of theDB_NAMEenvironment 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 components shown in the following table:Connect string Description db_type Type of database. The only currently supported database type is progress T T directs the SQL engine to use the TCP/IP protocol host_name Name of the system where the database resides port_num Port number to use for the connection db_name Name of the database - connection_name
-
The name of the connection as either a character literal or host variable. If the
CONNECTstatement omits a connection name, the default is the name of the database. Connection names must be unique. - username
-
User name for authentication of the connection. SQL verifies the user name against a corresponding password before it connects to the database. The value of the
DH_USERenvironment variable specifies the default user name. IfDH_USERis not set, the value of theUSERenvironment variable specifies the default user name. - password
-
Password for authentication of the connection. SQL verifies the password against a corresponding user name before it connects to the database.
The value of the
DH_PASSWDenvironment variable determines the default password.
Notes
- Arguments to
CONNECTmust be either string literals enclosed in quotation marks or character string host variables. - An application can connect to more than one database at a time, with a maximum of 10
connections. However, the application can actually gain access to only one database at a
time. The database name specified in the
CONNECTstatement becomes the active one. - If an application executes a SQL statement before connecting to a database, an attempt is made to connect to the environment-defined database, if any. If the connection is successful, the SQL statement is executed on that database.
Example
The following example illustrates the CONNECT statement:
|
- The first statement shown connects to the
salesdbdatabase on the local system. - The second statement connects to the
custdbdatabase on the local system. - The last statement connects to the environment-defined database by default.