|
|
CONNECT
Connects a user ident to a database.
Usage
Description
The ident is logged into the specified database. The database can exist on the local machine, a local database, or on another machine in a network configuration, a remote database.
The
database,connection,identand thepasswordcan be supplied either using a host variable or as a literal value.If an empty string is specified for
database, a connection is established to theDEFAULTdatabase, see the Mimer SQL System Management Handbook, The Default Database, for details on how theDEFAULTdatabase is defined in the Mimer SQL system.If
identis not specified (oridentis specified as blank), the name of the current operating system user is assumed. In that case, if anOS_USERident with that name exists in the selected database, a connect will be established without any password verification.Note: It is only possible to establish a connection to a remote database without specifying ident (or specifying a blank ident) if both the node on which the database resides and the node from which the connection is attempted are running the Windows operating system, and the NamedPipes protocol is used for the network communication.
It is not possible for the database server node to determine the name of the operating system user currently using the remote machine in other network configurations.When connected, the ident is able to access the database and becomes the current ident (i.e. the name the returned by
SESSION_USER).If
connectionis specified, the name must be a valid identifier or an empty string.Note: Connection names must be unique. If an empty string is specified, or if no connection name is given, the value of database will be used as the connection name.
Ident,password, andconnectionare case sensitive in theCONNECTstatement.
Databaseis not case sensitive in theCONNECTstatement.See SQL Identifiers for more information.
Restrictions
Only idents of type
USERandOS_USERcan connect to a database using theCONNECTstatement.Notes
If it is desired that a
CONNECT TO DEFAULTbe effectively performed, but with the possibility of specifying one or more ofconnection,identorpassword, then specifydatabase-specificsbut supply an empty string fordatabase.The maximum length of
database,identandconnectionis 128 characters.The maximum length of
passwordis 18 characters.If an SQL statement is executed in an application without first executing a
CONNECTstatement, an implicitCONNECT TO DEFAULTis performed.This requires that an
OS_USERident exist in the default database with the same name as the operating system user and that the default database either be a local database or a remote database residing on a node which allows the name of the current operating system user to be determined - see the related note in the Description section above for details.Such an implicit default connection will only be established if the
CONNECTstatement has not been previously executed in the application. This means that if an explicit connection has been previously established and then disconnected, any subsequent attempt to execute an SQL statement without a current connection will result in either aConnection does not existerror or a transaction rollback depending on the context of the SQL statement.If only the implicit default connection has been previously established and then disconnected, any subsequent attempt to execute an SQL statement without a current connection will result in that connection being re-established.
Observe that it is possible for the implicit default connection to exist but not be currently active (this will be the case if a connection has been subsequently established and then disconnected).
We recommend that Mimer SQL applications always establish explicit connections and reliance on the implicit default connection is discouraged.
Earlier versions of Mimer SQL used a different syntax for the
CONNECTstatement, see Deprecated Features. This syntax is still supported for backward compatibility, but its use is not recommended in new applications.Example
The following example connects the user
JOEtoproddatabaseusing the passwordhopPsan7:CONNECT TO 'proddatabase' USER 'JOE' USING 'hopPsan7';For more information, see the Mimer SQL User's Manual, Managing Database Connections.
Standard Compliance
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|