IBM PI19804: SQLCODE401 FROM DSNXOBFC FOR A SQL PROCEDURE WHEN USING INLIST IN IF STATEMENT - United States z/os  A FIX IS AVAILABLE
Obtain the fix for this APAR.


SUBSCRIBE
You can track all active APARs for this component.



APAR STATUS
 * CLOSED AS PROGRAM ERROR.
    
   
   

ERROR DESCRIPTION
 *  Sqlcode401 from dsnxobfc for a sql procedure when using inlist
   in if statement
   error will be received when coding something like this
   p1: begin
       decalre ws_types     char(2) default 'SN';
       declare ws_typew     char(2) default 'WS';
   
       if invar in (ws_types, ws_typew) then
          set outvar = 0;
       end if;
   
   Additional symptoms and search keywords
   SQLIN, SQLCODE401, SQLPROCEDURE, SQLSP, SQLSTOREDPROC
   
   
    
   
   

LOCAL FIX
 *  N/A
   
   
    
   
   

PROBLEM SUMMARY
 *  ****************************************************************
   * USERS AFFECTED: All DB2 11 for z/OS users of a compiled SQL  *
   *                 scalar function or native SQL procedure      *
   *                 containing control statement with IN-LIST    *
   *                 predicate which references SQL variables.    *
   ****************************************************************
   * PROBLEM DESCRIPTION: SQLCODE -401 or unexpected ABEND0C4     *
   *                      or ABEND04E may occur for a CREATE      *
   *                      PROCEDURE/FUNCTION statement that       *
   *                      contains control statement with an      *
   *                      IN-LIST predicate which references SQL  *
   *                      variables.                              *
   *                                                              *
   ****************************************************************
   * RECOMMENDATION:                                              *
   ****************************************************************
   The following examples help to illustrate the problem.
   
   Example#1. statement which issued SQLCODE -401 incorrectly.
   CREATE PROCEDURE SYSADM.CTEST(
     IN PCTYPE CHAR(4),
     OUT PRC INTEGER)
     LANGUAGE SQL
     DETERMINISTIC
     MODIFIES SQL DATA
     DYNAMIC RESULT SETS 1
     DISABLE DEBUG MODE
     PTEST: BEGIN
       DECLARE WC_CTYPE_PGMS CHAR(4) DEFAULT 'PGMS';
       DECLARE WC_CTYPE_PGMD CHAR(4) DEFAULT 'PGMD';
       IF PCTYPE IN (WC_CTYPE_PGMS, WC_CTYPE_PGMD) THEN
         SET PRC = 0;
       END IF;
       RETURN;
     END PTEST?
   
   Example#2. statement which issued ABEND0C4.
   CREATE PROCEDURE SYSADM.CTEST(
     IN PCTYPE CHAR(4),
     OUT PRC INTEGER)
     LANGUAGE SQL
     DETERMINISTIC
     MODIFIES SQL DATA
     DYNAMIC RESULT SETS 1
     DISABLE DEBUG MODE
     PTEST: BEGIN
       DECLARE WC_CTYPE_PGMS CHAR(4) DEFAULT 'PGMS';
       DECLARE WC_CTYPE_PGMD CHAR(4) DEFAULT 'PGMD';
       IF (CASE
             WHEN PCTYPE IN ('PGMS', 'PGMM', WC_CTYPE_PGMD, 'PGNN')
             THEN 'PGMM'
             ELSE 'PGMN'
           END
          ) = 'PGMM' THEN
         SET PRC = 0;
       END IF;
       RETURN;
     END PTEST?
   
   Example#3. statement which issued ABEND04E.
   CREATE PROCEDURE SYSADM.CTEST(
     IN PCTYPE CHAR(4),
     OUT PRC INTEGER)
     LANGUAGE SQL
     DETERMINISTIC
     MODIFIES SQL DATA
     DYNAMIC RESULT SETS 1
     DISABLE DEBUG MODE
     PTEST: BEGIN
       DECLARE WC_CTYPE_PGMS CHAR(4) DEFAULT 'PGMS';
       DECLARE WC_CTYPE_PGMD CHAR(4) DEFAULT 'PGMD';
       IF PCTYPE IN ('PGMS', 'PGMN', WC_CTYPE_PGMD, 'PGMG') THEN
         SET PRC = 0;
       END IF;
       RETURN;
     END PTEST?
   
   DB2 does not process the SQL variables in the IN-LIST predicate
   properly which can result in the incorrect SQLCODE or unexpected
   ABEND.
   
   
    
   
   

PROBLEM CONCLUSION
 *  DB2 has been modified correctly to process SQL variables in the
   IN-LIST predicate to avoid the problem.
   
   Additional keywords: SQLCODE401 SQLIN SQLCREATE SQLSP
                        SQLSTOREDPROC SQLNATIVESQLPL SQLUDF
                        SQLPROCEDURE
   
   
    
   
   

TEMPORARY FIX

COMMENTS

APAR INFORMATION
 * APAR NUMBER
   PI19804
   
   
 * REPORTED COMPONENT NAME
   DB2 OS/390 & Z/
   
   
 * REPORTED COMPONENT ID
   5740XYR00
   
   
 * REPORTED RELEASE
   B10
   
   
 * STATUS
   CLOSED PER
   
   
 * PE
   NoPE
   
   
 * HIPER
   NoHIPER
   
   
 * SPECIAL ATTENTION
   NoSpecatt
   
   
 * SUBMITTED DATE
   2014-06-12
   
   
 * CLOSED DATE
   2014-08-18
   
   
 * LAST MODIFIED DATE
   2014-10-02
   
   

 * APAR IS SYSROUTED FROM ONE OR MORE OF THE FOLLOWING:
   
   
   
 * APAR IS SYSROUTED TO ONE OR MORE OF THE FOLLOWING:
    UI20622
   
   

MODULES/MACROS
 *  DSNXOP0
   
   
    
   
   

FIX INFORMATION
 * FIXED COMPONENT NAME
   DB2 OS/390 & Z/
   
   
 * FIXED COMPONENT ID
   5740XYR00
   
   

APPLICABLE COMPONENT LEVELS
 * RB10 PSY UI20622 [HTTPS://WWW14.SOFTWARE.IBM.COM/WEBAPP/SET2/ORDERMEDIA/SHOPCART?PTFS=UI20622]
   UP14/09/03 P F409
   
   

FIX IS AVAILABLE
 * SELECT THE PTF APPROPRIATE FOR YOUR COMPONENT LEVEL. YOU WILL BE REQUIRED TO SIGN IN. DISTRIBUTION ON PHYSICAL MEDIA IS NOT AVAILABLE IN ALL COUNTRIES.

Question: DSNT408I SQLCODE -401 creating stored procedure CIUSNTSR after upgrading to DB2 11 

Why would CIUSNTSR stored procedure creation fail with message DSNT408I and SQLCODE=-401? I am running CICS Interdependency Analyzer for z/OS (CICS IA) CIUDBCQ JCL when the failure occurs. This happened after I upgraded z/OS DB2 to V11.

Here are the messages I receive:

     DSNT408I SQLCODE = -401, ERROR:  THE OPERANDS OF AN ARITHMETIC OR COMPARISON OPERATION ARE
     NOT COMPARABLE
     DSNT418I SQLSTATE  = 42818 SQLSTATE RETURN CODE
     DSNT415I SQLERRP   = DSNXOBFC SQL PROCEDURE DETECTING ERROR
     DSNT416I SQLERRD   = 930 0  1  -1  0  0 SQL DIAGNOSTIC INFORMATION
     DSNT416I SQLERRD   = X'000003A2' X'00000000' X'00000001' X'FFFFFFFF' X'00000000' X'00000000'
     SQL DIAGNOSTIC INFORMATION


Answer: DB2 has been modified correctly to process SQL variables in the
   IN-LIST predicate to avoid the problem.