DECLARE AUDIT INFO SET (Set user connection information)

Function

DECLARE AUDIT INFO SET specifies, for applications that access a HiRDB server, account information and other user connection information. The specified user connection information remains in effect until it is terminated, and is output to the HiRDB server's audit trail when the SQL code is executed.

Format

DECLARE AUDIT INFO SET POS=:embedded-variable,
                      INF=:embedded-variable[:indicator-variable]

Operands

Specifies the number of additional user information items that are to be set as INTEGER type embedded variables. The numbers corresponding to each additional user information item are as follows:

Specifies the user connection information as an embedded variable declared as a VARCHAR type (area length of 100 bytes or less). Specify the null value to remove information that has already been set. Additional user information item 1 through additional user information item 3 is included in the user connection information, and all are output in the audit trail.

Character sets other than the default character set cannot be specified.

Common rules

  1. The embedded variable to be used must be declared in the embedded variable declaration section.
  2. Error codes are returned in SQLCODE.
  3. If DECLARE AUDIT INFO SET is re-executed when user connection information is already set, the existing user connection information is updated.
  4. The user connection information that is set is in effect until terminated by setting a null value in DECLARE AUDIT INFO SET. The figure below shows the effective scope of the user connection information that is set in DECLARE AUDIT INFO SET.

    Figure 6-6 Effective scope of user connection information set in DECLARE AUDIT INFO SET

    [Figure]

  5. If user connection information is set in DECLARE AUDIT INFO SET before the CONNECT statement is executed, that information is carried over for the CONNECT.
  6. If DISCONNECT is executed while user connection information is set, the user connection information is not cleared. To clear it, specify the null value in INF and execute DECLARE AUDIT INFO SET.
  7. If there are multiple connections, the user connection information must be set separately for each connection handle.

Note

  1. When the CONNECT statement is executed, user connection information is not output to the audit trail.

Examples

Example 1: Set user connection information (additional user information item 1 through 3) that is specified in an embedded variable.

EXEC SQL BEGIN DECLARE SECTION ;
SQL TYPE IS VARCHAR(100) udata ;
long pos ;
EXEC SQL END DECLARE SECTION ;

strcpy(udata.str,"userA") ;
udata.len = strlen(udata.str) ;
pos = 1;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata ;
strcpy(udata.str," user data B ") ;
udata.len = strlen(udata.str) ;
pos = 2;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata ;
strcpy(udata.str," user data C ") ;
udata.len = strlen(udata.str) ;
pos = 3;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata ;

Example 2: Clear the contents of the user connection information (additional user information items 1 through 3).

EXEC SQL BEGIN DECLARE SECTION ;
SQL TYPE IS VARCHAR(100) udata ;
long pos ;
short ind ;
EXEC SQL END DECLARE SECTION ;

ind = -1;
pos = 1;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata:ind ;
pos = 2;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata:ind ;
pos = 3;
EXEC SQL DECLARE AUDIT INFO SET POS=:pos, INF=:udata:ind ;