Connection Statements

 <     >  Connection Example Connection Flow Chart Table of Contents


InstantSQL provides the following statements to support connecting to and disconnecting from data sources:





Connect to a data source.


Disconnect from a connected data source.


Specify the user for connecting to a data source.


Shutdown InstantSQL (disconnect all data sources).

Before any activity can be performed on a data source, the RM/COBOL program must connect to the desired data source. The SQL CONNECT DATASOURCE statement connects an application to a named data source. Many data sources require a user login to enable access to the data. Thus, a user name and user password may be supplied in the SQL CONNECT DATASOURCE statement or in a prior SQL SET USER statement. User information can also be omitted, in which case the default behavior of InstantSQL is to prompt for the information if it is needed. An optional login timeout value may also be specified in the SQL CONNECT DATASOURCE statement.

A successful SQL CONNECT DATASOURCE statement returns an InstantSQL handle value for the connection. This connection handle value must be provided to other InstantSQL statements to identify the connection. Any activity on a data source requires a connection. Therefore if you wish to perform queries or browse the structure of a data source, you must first connect to the data source. Any number of queries may be performed on the data source up to the limitations of InstantSQL, Windows ODBC or the ODBC driver that supports the data source.

Information about a connection, including information about the connected data source, may be obtained with the status inquiry statement SQL DESCRIBE CONNECTION.

After the desired activities have been completed on the data source, the data source should be disconnected. The SQL DISCONNECT DATASOURCE statement disconnects the application from a connected data source. If transactions are being used, any active transactions must be ended before disconnecting.

Once all InstantSQL activity is finished, the SQL SHUTDOWN statement should be executed to free all resources used by InstantSQL. This is normally done as one of the application termination activities. If any data sources are still connected, the SQL SHUTDOWN statement will disconnect them.

Data source names for connecting to data sources may be discovered by use of the InstantSQL browse statement SQL QUERY DATASOURCES, which does not require a prior connection.

Copyright 2000-2020 Micro Focus or one of its affiliates.