Example 1: Execute SQL statements at TOROLAB and SVLLAB. The first CONNECT statement creates the TOROLAB connection and the second CONNECT statement places it in the dormant state.
EXEC SQL CONNECT TO TOROLAB; (execute statements referencing objects at TOROLAB) EXEC SQL CONNECT TO SVLLAB; (execute statements referencing objects at SVLLAB)
Example 2: Connect to a remote server specifying a userid and password, perform work for the user and then connect as another user to perform further work.
EXEC SQL CONNECT TO SVLLAB USER :AUTHID USING :PASSWORD; (execute SQL statements accessing data on the server) EXEC SQL COMMIT; (set AUTHID and PASSWORD to new values) EXEC SQL CONNECT TO SVLLAB USER :AUTHID USING :PASSWORD; (execute SQL statements accessing data on the server)
Example 3: User JOE wants to connect to TOROLAB3 and execute SQL statements under the user ID ANONYMOUS which has a password of SHIBBOLETH. The RDB directory entry for TOROLAB3 specifies *IP for the connection type.
Before running the application, some setup must be done.
This command will be required to allow server security information to be retained in i5/OS, if it has not been previously run:
CHGSYSVAL SYSVAL(QRETSVRSEC) VALUE('1')
This command adds the required server authorization entry:
ADDSVRAUTE USRPRF(JOE) SERVER(TOROLAB3) USRID(ANONYMOUS) + PASSWORD(SHIBBOLETH)
This statement, run under JOE's user profile, will now make the desired connection:
EXEC SQL CONNECT TO TOROLAB3; (execute statements referencing objects at TOROLAB3)
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.