Programming Guide



DECLARE CONNECTION

Creates a named connection to a database engine

Synopsis

DBMS [WITH ENGINE engine] DECLARE connection CONNECTION
[WITH option=argVar [,... ]]
DBMS [WITH ENGINE engine] DECLARE connection CONNECION
[FOR option arg ...]

Arguments

WITH ENGINE engine
Name of engine to associate with the connection. If the clause is not used, Panther opens the connection on the default engine.

connection
Name of connection to be opened.

option
Name of connection option. Names and number of available options is engine-specific.

argVar
Variable that contains the value assigned to the option, or a quoted string. Use this variant when the value might contain spaces and/or punctuation. Spaces are permitted around the equal sign.

arg
Literal value, either a quoted string or a colon-expanded expression, assigned to the connection option.

Description

DBMS DECLARE CONNECTION opens a session on a database engine. If the statement executes successfully, it allocates a connection structure and adds it to the list of open structures.

Applications which must connect to two or more database servers should declare a named connection to each server. If you are connecting to two or more database engines, you must declare a connection for each engine.

The combination of necessary or supported options is engine-specific. Common options include USER, PASSWORD, DATABASE, and SERVER. For a list of the valid options, refer to "Database Drivers."

Options can be specified using either of two ways:

The connection remains open until it is closed with CLOSE CONNECTION or CLOSE_ALL_CONNECTIONS.

For additional information, refer to Chapter 8, "Connecting to Databases," in Application Development Guide.

Example

// This procedure connects to the database and has 
// two variables for the user and password.
proc logon
DBMS DECLARE c1 CONNECTION \ 
WITH USER=user, PASSWORD=pword, \
DATABASE="C:\Program Files\video\videobiz"
return
// Same example as above, but using FOR rather 
// than WITH. Note that the variable names are
// quoted and colon-expanded.
proc logon
DBMS DECLARE c1 CONNECTION \
FOR USER ":user" PASSWORD ":pword" \
DATABASE "C:\Progra~1\video\videobiz"
return

See Also

CLOSE CONNECTION, CLOSE_ALL_CONNECTIONS, CONNECTION, WITH CONNECTION, dm_get_db_conn_handle, dm_is_connection