15.10 - Explicit Connection - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

prodname
Preprocessor2 for Embedded SQL
vrm_release
15.10
category
Programming Reference
featnum
B035-2446-035K

Explicit connection permits precise control over which tdp and userid to connect to. Implicit connection uses system defaults for the tdp and userid. (See “Implicit Connection” on page 53). For this reason, make an explicit connection to connect to a nondefault tdp or userid.

Explicit connections are generally advocated because of this precise control, even when default tdps and userids are satisfactory for the required level of security.

Specify an explicit connection to the Teradata Database with a CONNECT or LOGON statement, which are described in SQL Stored Procedures and Embedded SQL (B035‑1148).

 

Statement

Specifications

CONNECT

Specify only the userid and password. The tdpid is taken from the system default value.

The CONNECT userid and password are each restricted to eight characters.

This statement is IBM SQL‑compatible.

LOGON

Specify a complete Teradata Database logon string, including tdpid and accountid.

The userid and password each can be a maximum of 30 characters.

Note: On Windows platforms only:

1 The <userid> and <password> are optional on Windows NT.

2 A LOGON string without a <userid> and <password> is interpreted as an SSO logon.

If an explicit connection request is made when a connection or a transaction is already active, the following actions are taken.

 

Connection or Transaction Status

Action Taken

The application is already connected to the Teradata Database.

The previous connection is dropped before the new connection is attempted.

A transaction is active.

  • The connection request is rejected with a SQLCODE of ‑752.
  • The application must terminate the current transaction explicitly using one of the following before attempting to issue a new explicit connection request:
  • COMMIT
  • ROLLBACK (or ABORT)
  • LOGOFF
  • Extended Security with LOGMECH and LOGDATA

    Network versions of PP2 09.01.00 and above support LOGMECH and LOGDATA statements for use with logon mechanisms. The mainframe‑attached version of PP2 does not support these statements.

    Syntax

    LOGMECH type
    LOGDATA:data_address
     

    C Example

    EXEC SQL BEGIN DECLARE SECTION;
     	VARCHAR  LOGON_STRING[40];
     	VARCHAR  LOGDATA_STRING[40];
      EXEC SQL END DECLARE SECTION;
     
      EXEC SQL
     	LOGMECH LDAP;
     
      strcpy (LOGDATA_STRING.arr, "authcid=guestldap password=password");
      LOGDATA_STRING.len = strlen(LOGDATA_STRING.len);
      EXEC SQL
     	LOGDATA :LOGDATA_STRING;
     
      strcpy (LOGON_STRING.arr, "tdname");
      LOGON_STRING.len = 6;
      EXEC SQL
      	LOGON :LOGON_STRING;

    Cobol Example

    01  LOGON-STRING.                                         
                49 FILLER         PIC S9(4) COMP VALUE +5.           
                49 FILLER         PIC X(5) VALUE 'TDP1/'.            
                                                                      
            01  LOGDATA-STRING.                                       
                49 FILLER         PIC S9(4) COMP VALUE +28.           
                49 FILLER PIC X(28)                                   
                          VALUE 'GUEST@KRB5DOM.PROD@@PASSWORD’
                                                                      
                                                             
                EXEC SQL                                     
                         LOGMECH KRB5                        
                END-EXEC.                                    
                                                             
                EXEC SQL                                     
                         LOGDATA :LOGDATA-STRING             
                END-EXEC.                                    
                                                             
                EXEC SQL                                     
                         LOGON :LOGON-STRING                 
                END-EXEC. 

    If LOGMECH and LOGDATA statements are used to pass logon credentials to the database, it may not be necessary to use the default LOGON dialog box in GUI applications. It depends on the type of logon mechanism that is used. To disable the LOGON dialog box, specify GUILOGON=NO as an environmental variable.