Chapter Contents

Previous

Next
CONNECT Statement

CONNECT Statement



Establishes a connection with the DBMS

Optional statement


Syntax
Arguments
Informix Connection Arguments
Example

Syntax

CONNECT TO INFORMIX <AS alias> <(Informix-connection-arguments)>;

Arguments

alias
specifies an optional alias that has 1 to 32 characters. If you specify an alias, the keyword AS must appear before the alias.

(Informix-connection-arguments)
specifies the arguments that are needed by PROC SQL in order to connect to the Informix. These arguments must be enclosed in parentheses.


Informix Connection Arguments

The CONNECT statement establishes a connection with the DBMS. You establish a connection to send SQL statements to the DBMS or to retrieve DBMS data. The connection remains in effect until you issue a DISCONNECT statement or terminate the SQL procedure.

You can connect to only one Informix database. However, you can specify multiple CONNECT statements if they all connect to the same Informix database. If you use multiple connections, you must use an alias to identify the different connections. If you omit an alias, informix is automatically used.

When you omit a CONNECT statement, an implicit connection is performed when the first EXECUTE statement or CONNECTION TO component is passed to the DBMS.

The CONNECT statement is optional when connecting to an Informix database if the DBDATABASE environment variable has been set to include both the database and server specification. See Using the DBDATABASE Environment Variable for more information.

Any return code or message that is generated by the DBMS or by the SQL Procedure Pass-through facility is available in the macro variables SQLXRC and SQLXMSG after the statement executes.

Informix uses the following database connection arguments. These arguments must be enclosed in parentheses.

DATABASE= | DB=<">database-name<">
specifies the name of the Informix database and optionally, database server, to which PROC SQL connects. The database name allows optional single or double quotes. If the name contains special characters, national characters, or semicolons, you must enclose the name in quotes.

By using a full pathname, you can specify a database as well as a database server in the DATABASE argument.

You can set default values for the DATABASE= argument and therefore, the argument is optional. See Using the DBDATABASE Environment Variable for more information.

SERVER=<'>server-name<'>
specifies the server with which to connect. This server accesses the database that contains the tables and views that you want to access. If you omit the SERVER= option, the value of the SAS environment variable INFORMIXSERVER is used as the server name. An error occurs if neither the SERVER= option nor the SAS INFORMIXSERVER environment variable is set.

You can use the DBDATABASE environment variable to specify database/server combinations, such as database@server or //server/database.

USER=<'>Informix-user-name<'>
specifies the Informix user name that you use to connect to the database that contains the tables and views that you want to access. If you omit the USER= option, your operating system account name is used, if applicable to your operating environment.

USING=<'>Informix-password<'>
specifies the password that is associated with the Informix user. If you omit the password, Informix uses the password in the /etc/password file.

USING can also be specified with the PASSWORD= and PWD=aliases.


Example

This example connects to the Informix database stores7 by using the online server. The database name is quoted because it includes special characters.

proc sql;
   connect to informix
   (user=SCOTT password=TIGER database='//online/stores7');

Note:   You can use the DBDATABASE environment variable to specify database/server combinations, such as database@server or //server/database.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.