ADMIN_INFO_HOST stored procedure
The SYSPROC.ADMIN_INFO_HOST stored procedure returns the hostname of a connected Db2 subsystem or the hostname of every member of a data sharing group.
Environment
ADMIN_INFO_HOST runs in a WLM-established stored procedures address space.
Authorization
To execute the CALL statement, the owner of the package or plan that contains the CALL statement must have one or more of the following privileges on each package that the stored procedure uses:
- The EXECUTE privilege on the package for DSNADMIH
- Ownership of the package
- PACKADM authority for the package collection
- SYSADM authority
The ADMIN_INFO_HOST stored procedure internally calls the ADMIN_COMMAND_DB2 stored procedure to execute the following Db2 commands:
- -DISPLAY DDF
- -DISPLAY GROUP
The owner of the package or plan that contains the CALL ADMIN_INFO_HOST statement must also have the authorization required to execute the stored procedure ADMIN_COMMAND_DB2 and the specified Db2 commands. To determine the privilege or authority required to issue a Db2 command, see Db2 commands.
Syntax
The following syntax diagram shows the SQL CALL statement for invoking this stored procedure:
Option descriptions
- processing-option
- Specifies processing option. Possible values are:
- 1
- Return the hostname of the connected Db2 subsystem or the hostname of a specified Db2 data sharing group member.
For a data sharing group member, you must specify db2-member.
- 2
- Return the hostname of every Db2 member of the same data sharing group.
This is an input parameter of type INTEGER and cannot be null.
- DB2-member
- Specifies the Db2 data sharing group
member name.
This parameter must be null if processing-option is 2.
This is an input parameter of type CHAR(8).
- return-code
- Provides the return code from the stored procedure. Possible values are:
- 0
- The call completed successfully.
- 4
- Unable to list the hostname of the connected Db2 subsystem or of every Db2 member of the same data sharing group due to one
of the following reasons:
- The IPADDR field returned when the -DISPLAY DDF command is executed on the connected Db2 subsystem or Db2 member contains the value -NONE
- One of the Db2 members is down
- 12
- The call did not complete successfully. The message output parameter contains messages describing the error.
This is an output parameter of type INTEGER.
- message
- Contains messages describing the error encountered by the stored procedure. If no error
occurred, then no message is returned.
The first messages in this area are generated by the stored procedure. Messages that are generated by Db2 might follow the first messages.
This is an output parameter of type VARCHAR(1331).
Example
The following C language sample shows how to invoke ADMIN_INFO_HOST:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/******************** DB2 SQL Communication Area ********************/
EXEC SQL INCLUDE SQLCA;
int main( int argc, char *argv[] ) /* Argument count and list */
{
/****************** DB2 Host Variables ****************************/
EXEC SQL BEGIN DECLARE SECTION;
/* SYSPROC.ADMIN_INFO_HOST parameters */
long int procopt; /* Processing option */
short int ind_procopt; /* Indicator variable */
char db2mbr[9]; /* Data sharing group member */
/* name */
short int ind_db2mbr; /* Indicator variable */
long int retcd; /* Return code */
short int ind_retcd; /* Indicator variable */
char errmsg[1332]; /* Error message */
short int ind_errmsg; /* Indicator variable */
/* Result set locators */
volatile SQL TYPE IS RESULT_SET_LOCATOR *rs_loc1;
/* Result set row */
long int rownum; /* Sequence number of the */
/* table row */
char db2member[9]; /* DB2 data sharing group */
/* member name */
char hostname[256]; /* Host name of the connected */
/* DB2 subsystem or DB2 */
/* member name */
EXEC SQL END DECLARE SECTION;
/******************************************************************/
/* Assign values to input parameters to find the hostname of */
/* the connected DB2 subsystem */
/* Set the indicator variables to 0 for non-null input parameters */
/* Set the indicator variables to -1 for null input parameters */
/******************************************************************/
procopt = 1;
ind_procopt = 0;
ind_db2mbr = -1;
/******************************************************************/
/* Call stored procedure SYSPROC.ADMIN_INFO_HOST */
/******************************************************************/
EXEC SQL CALL SYSPROC.ADMIN_INFO_HOST
(:procopt :ind_procopt,
:db2mbr :ind_db2mbr,
:retcd :ind_retcd,
:errmsg :ind_errmsg);
/******************************************************************/
/* Retrieve result set when the SQLCODE from the call is +446, */
/* which indicates that result sets were returned */
/******************************************************************/
if (SQLCODE == +466) /* Result sets were returned */
{
/* Establish a link between the result set and its locator */
EXEC SQL ASSOCIATE LOCATORS (:rs_loc1)
WITH PROCEDURE SYSPROC.ADMIN_INFO_HOST;
/* Associate a cursor with the result set */
EXEC SQL ALLOCATE C1 CURSOR FOR RESULT SET :rs_loc1;
/* Use C1 to fetch the only row from the result set */
EXEC SQL FETCH C1 INTO :rownum, :db2mbr, :hostname;
EXEC SQL CLOSE C1;
}
return(retcd);
}
Output
This stored procedure returns the following output parameters, which are described in Option descriptions:
- return-code
- message
In addition to the preceding output, the stored procedure returns one result set that contains the hostnames.
The following table shows the format of the result set returned in the created global temporary table SYSIBM.SYSTEM_HOSTNAME:
Column name | Data type | Contents |
---|---|---|
ROWNUM | INTEGER | Sequence number of the table row, from 1 to n. |
DB2_MEMBER | CHAR(8) | Db2 data sharing group member name. |
HOSTNAME | VARCHAR(255) | Host name of the connected Db2 subsystem if the processing-option input parameter is 1 and the db2-member input parameter is null. Otherwise, the hostname of the Db2 member specified in the DB2_MEMBER column. |