CONNECT

Syntax

CONNECT {txt_lit|_var|_col}[ON-ERROR=procedure[(arg1 [, argi]...)]]

Description

Logs off the database and logs on under a new username and password.

The new username and password can be stored in a string variable, column, or literal.

WARNING:

The username and password are not encrypted, so beware of security issues.

After each CONNECT, the reserved variable $username is set to the new username.

All database cursors or logons are closed before the CONNECT occurs. You should not issue a CONNECT within a SELECT or an SQL paragraph while a query is actively fetching or manipulating data from the database.

Parameters

Parameter Description

txt_lit|_var|_col

Specifies a username and password for the logon.

ON-ERROR

Specifies a procedure to be run if the logon fails. If no ON-ERROR procedure is specified and the logon fails, SQR halts with an error message.

Note:

You can optionally specify arguments to be passed to the ON-ERROR procedure. Arguments can be any variable, column, or literal.

Example

The following example illustrates the CONNECT command:

connect  $new-user  on-error=bad-logon($new_user)
connect  'sqr/test'