Previous Topic
Table Of Contents
Parent Topic
Next Topic

High-Level Language SWSERROR (SWCPSE) Function

Related Topics

Web Server API Function Index


May be used in Shadow/REXX
May be used from Other REXX Interpreters
HLL entry point name is SWCPSE

SWSERROR is the Web Server API function used to fetch information pertaining to the last Application Program Interface error detected for this transaction.

CALL Arguments

The SWSERROR function call requires eight arguments. None may be omitted from the function call.

Arg.
No.
HLL Argument Type I/O Description of Argument
C COBOL PL/I
1 HENV USAGE POINTER PTR Input The Web Server environment handle. The environment handle is an opaque, four-byte address pointer. The environment handle is currently not used, and must be set to zero (NULL).
2 HDBC USAGE POINTER PTR Input The Web Server connection handle. The connection handle is an opaque, four-byte address pointer. The connection handle is currently not used, and must be set to zero (NULL).
3 HSTMT USAGE POINTER PTR Input The Web Server statement handle. The statement handle is an opaque, four-byte address pointer. The statement handle is currently not used, and must be set to zero (NULL).
4 UCHAR * PIC X(6) CHAR(6) Output This argument should specify a character string buffer of at least 6 bytes in length. A state value, compatible in format with the ODBC specification is returned in this area, as a null terminated string.
5 SDWORD * PIC S9(5) COMP FIXED BIN(31) Output The 'native' error code is returned within this area. This is some value that describes the error condition.
6 UCHAR * PIC X(nnn) CHAR(nnn) Output The buffer area which receives the error message text. Note that the error message text will always be null-terminated. Room for the trailing null must be provided.
7 SDWORD PIC S9(5) COMP FIXED BIN(31) Input The total size of the error message buffer area supplied by the sixth argument. The error message will be truncated if it does not fit into this buffer, including room for the trailing null terminator.
8 SDWORD * PIC S9(5) COMP FIXED BIN(31) Output The API returns the total size of the error message (excluding the null terminator). The returned size value will be larger than the buffer size if the error message has been truncated.

 

Return Values

SWSERROR always sets a signed numeric return code value. Possible values are:

SWS_SUCCESS
The operation succeeded. The return values have been set.
SWS_SUCCESS_WITH_INFO
The operation partially succeeded. This return code value is set when the returned error message text has been truncated.
SWS_ERROR
A parameter validation or run-time error was encountered. Error information is available using the SWSERROR function.
SWS_ENVIRONMENT_ERROR
The request can not be processed because of a run-time environmental error. For example, you invoked the API service outside of a Web transaction procedure or from outside the server's address space. Use the server's wrap-around trace to obtain diagnostic information.
SWS_NO_DATA_FOUND
There is no prior error condition upon which to report.
SWS_INVALID_HANDLE
One of the handle arguments is invalid.
 

PL/I Example


 
    DCL  SENVH     PTR;                 /* Environment Handle      */
    DCL  SCONN     PTR;                 /* Connection Handle       */
    DCL  SSTMT     PTR;                 /* Statment Handle         */
    DCL  SSQST     CHAR(6);             /* ODBC State              */
    DCL  SNATV     FIXED BIN(31);       /* Native Error Code       */
    DCL  SERMG     CHAR(256);           /* error message text      */
    DCL  SMGSZ     FIXED BIN(31) INIT(256);  /* Buffer size        */
    DCL  SRTSZ     FIXED BIN(31);       /* Fetched value size      */
    DCL  RC        FIXED BIN(31);       /* return code             */
    DCL  DMHX      FIXED BIN(31) BASED; /* Dummy Handle field      */
 
    ADDR(SENVH)->DMHX = 0;              /* Clear Environment Hndl. */
    ADDR(SCONN)->DMHX = 0;              /* Clear Connection Handle */
    ADDR(SSTMT)->DMHX = 0;              /* Clear Statement Handle  */
 
    CALL SWSERROR( SENVH,               /* get last error info     */
                   SCONN,
                   SSTMT,
                   SSQST,
                   SNATV,
                   SERMG,
                   SMGSZ,
                   SRTSZ );
    RC = PLIRETV();                     /* get return code         */
    IF (RC ^= SWS_SUCCESS &             /* exit program if bad RC  */
        RC ^= SWS_SUCCESS_WITH_INFO) THEN
       EXIT;

Top

C Example


 
    HDBC   sEnvh   = NULL;              /* Environment Handle      */
    HDBC   sConn   = NULL;              /* Connection Handle       */
    HSTMT  sStmt   = NULL;              /* Statement Handle        */
    char   sSqst[6];                    /* ODBC-Compatible state   */
    SDWORD sNatv;                       /* Native Error Code       */
    char   sErmg[256];                  /* Error message text      */
    SDWORD sRtsz;                       /* Error message size      */
 
    rc = SWSError( &sEnvh,              /* get error information   */
                   &sConn,
                   &sStmt,
                   sSqst,
                   &sNatv,
                   sErmg,
                   sizeof(sErmg),
                   &sRtsz );
    if (rc ^= SWS_SUCCESS) return;      /* exit program if bad RC  */
 

Top

COBOL Example


 
    77  SENVH                USAGE IS POINTER.
    77  SCONN                USAGE IS POINTER.
    77  SSTMT                USAGE IS POINTER.
    77  SSQST                PIC X(6).
    77  SNATV                PIC S9(5) COMP.
    77  SERMG                PIC X(256).
    77  SMGSZ                PIC S9(5) COMP VALUE 256.
    77  SRTSZ                PIC S9(5) COMP.
 
 
    CALL 'SWCPSE' USING SENVH,
                  SCONN,
                  SSTMT,
                  SSQST,
                  SNATV,
                  SERMG,
                  SMGSZ,
                  SRTSZ.
    MOVE RETURN-CODE TO WS-SWSAPI-RETURN-CODE.
    IF NOT SWS-SUCCESS GOBACK.
 

Top