DBconnect


Synopsis

DBconnect connects the user to or disconnects the user from a database.

Input ports

database_driver string
server_host string
server_name string
database_name string
user_id string
user_password string
connect_string string
connect_disconnect int

Parameters

log_filename string
append_mode int
connect_status int
message string
return_code int

Output ports

dbvisual_connect_descriptor ptr to a structure

Description

DBconnect connects the user to or disconnects the user from a database by executing a SQL CONNECT or DISCONNECT statement. A connect establishes a connection between a user and a database and initiates a session with the database. A disconnect terminates the session and breaks the connection. The value assigned to the connect_disconnect input port determines whether the server performs a connect or a disconnect.

Connection Requirements

When connecting, the user must supply, at minimum, the following:

•      A database driver name. The database driver indicates the type of database to which the user will connect; for example, ORACLE.

•      Either a connect string or the elements from which to construct a connect string. DBconnect constructs a connect string only if the user does not supply one.

•      The value 1 for the connect_disconnect parameter, to indicate that a connect is desired.

A user name is always required for a connect string. Depending on the database type, as indicated by the database driver, one or more of the following may also be required:

•      a user password

•      a server name

•      a server host name

•      a database name or alias

Which elements are required and how they are assembled into a connect string are specific to the type of database. For more information, see The Toolkits Book or your database documentation.

Disconnection requirements

When disconnecting, the user needs to supply only the value 0 for the connect_disconnect parameter to indicate that a disconnect is desired.

Input ports

database_driver

The name of the database driver, which indicates the type of database; for example, ORACLE. The default is the value of the environment variable XP_DB_DRIVER, if set, otherwise there is no default.

server_host

The host name of the machine on which the server that manages the database resides. The default is the value of the environment variable XP_SERVER_HOST, if set, otherwise there is no default. If the user does not specify a server host, either explicitly or by default, DBconnect uses the default server host for the specified database driver.

This value is required only if the user does not supply a value for connect_string and the specified database driver requires a server host name in the connect string. If a value is specified for connect_string, this parameter is ignored.

server_name

The name of the server that manages the database. The default is the value of the environment variable XP_SERVER_NAME, if set, otherwise it is default server for the specified database driver.

This value is required only if the user does not supply a value for connect_string and the specified database driver requires a server name in the connect string. If a value is specified for connect_string , this parameter is ignored.

database_name

The database to which to connect. The default is the value of the environment variable XP_DATABASE_NAME, if set, otherwise it is default database for the specified database driver.

This value is required only if the user does not supply a value for connect_string and the specified database driver requires a database name in the connect string. If a value is specified for connect_string , this parameter is ignored.

user_id

The user's ID on the host system. The default is the value of the environment variable XP_USER_ID, if set, otherwise there is no default.

This value is required only if the user does not supply a value for connect_string . If a value is specified for connect_string, this parameter is ignored.

user_password

The user's password on the host system. The default is the value of the environment variable XP_USER_PASSWORD, if set, otherwise there is no default.

This value is required only if the user does not supply a value for connect_string and the specified database driver requires a user password in the connect string. If the required information is specified for connect_string, this parameter is ignored.

connect_string

The connect string that the database server will use to connect the user to the specified database. The default is the value of the environment variable XP_CONNECT_STRING, if set, otherwise there is no default.

The format of a connect string is specific to the type of database (as specified with database_driver).

If a value for connect_string is not supplied, the user must supply the elements from which to construct a connect string. The values required for constructing a connect string are also database specific.

For a discussion of connect string format and the values required for constructing a connect string, see either The Toolkits Book or your database documentation.

connect_disconnect

A value that specifies whether the user wants to connect to or disconnect from the database. A value of 1 (the default) indicates connect; 0 indicates disconnect.

Parameters

log_filename

The name of a file in which data about the current session is logged. AVS/Express logs all communications between the user and the database beginning with the connect and ending with the disconnect. The default filename is / tmp / DBlogfile .

append_mode

A value that specifies whether AVS/Express creates a new log file or appends log data to an existing log file. A value of 1 (the default) appends log data to the existing file; 0 creates a new file.

•      Note: If the log file already exists and you do not specify a different log file for your current session, the previous contents of the file will be lost.

connect_status

The status of the connect or disconnect. A value of 0 means disconnected and a value of 1 means connected.

message

An message that describes the status of the connect or disconnect. For a list of possible values, see ."

return_code

The status code associated with the message returned in the message parameter. A value of 0 indicates success; a nonzero value indicates failure. For a list of possible values, see The Toolkits Book .

Output ports

dbvisual_connect_descriptor

A pointer to a connection descriptor for the connection that is being established or broken and the session being initiated or terminated.

File

v/db.v

See Also

•