The document discusses common Cobol problems when interacting with SQL including:
- Invalid bind variable issues when the number of binds set in Cobol does not match those in the SQL statement.
- Invalid datatype errors occurring when not enough bind variable values are assigned in Cobol for the binds in the SQL statement.
- Invalid select item errors happening when the number of fields selected in SQL does not equal the number of select buffers defined in Cobol.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
312 views
Common Cobol Problem Diagnosis
The document discusses common Cobol problems when interacting with SQL including:
- Invalid bind variable issues when the number of binds set in Cobol does not match those in the SQL statement.
- Invalid datatype errors occurring when not enough bind variable values are assigned in Cobol for the binds in the SQL statement.
- Invalid select item errors happening when the number of fields selected in SQL does not equal the number of select buffers defined in Cobol.
• You must have a Bind Variable in the SQL • For every Bind Variable in SQL • You must have a Bind setup in Cobol • For every Field in a Record for an INSERT • You must have a value assigned • This is not necessarily done solely by Bind Variables Invalid Bind Variable
12:10:19 576 0.016 0.000 #1 RC=0 COM Stmt=SELECT REFUND_DTTM FROM PS_REFUND_HDR A WHERE A.BUSINESS_UNIT = :1 AND A.EMPLID = :2 AND A.REFUND_NBR = :3 AND A.REFUND_DTTM = (SELECT MAX(B.REFUND_DTTM) FROM PS_REFUND_HDR B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.EMPLID = B.EMPLID AND B.REFUND_TYPE IN ('F','N','O','B') AND B.REFUND_STATUS = :4) 12:10:19 577 0.016 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=5, value=PSUNV 12:10:19 578 0.015 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=9, value=ADCRM1001 12:10:19 579 0.016 0.000 #1 RC=0 Bind-3, type=SQLPBUF, length=1, value=C 12:10:19 580 0.016 0.000 #1 RC=0 SSB column=1, type=SQLPDAT, length=26 12:10:19 581 0.015 0.000 #1 RC=8006 EXE 12:10:19 582 0.047 0.000 #0 RC=8006 ERR rtncd=8006 msg=Invalid datatype specified
3 Bind Variable Values setup by cobol
Invalid Datatype 4 Bind Variables in SQL 12:10:19 575 0.016 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_S_BORFNDT, length=321 12:10:19 576 0.016 0.000 #1 RC=0 COM Stmt=SELECT REFUND_DTTM FROM PS_REFUND_HDR A WHERE A.BUSINESS_UNIT = :1 AND A.EMPLID = :2 AND A.REFUND_NBR = :3 AND A.REFUND_DTTM = (SELECT MAX(B.REFUND_DTTM) FROM PS_REFUND_HDR B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.EMPLID = B.EMPLID AND B.REFUND_TYPE IN ('F','N','O','B') AND B.REFUND_STATUS = :4) 12:10:19 577 0.016 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=5, value=PSUNV 12:10:19 578 0.015 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=9, value=ADCRM1001 12:10:19 579 0.016 0.000 #1 RC=0 Bind-3, type=SQLPBUF, length=1, value=C 12:10:19 580 0.016 0.000 #1 RC=0 SSB column=1, type=SQLPDAT, length=26 12:10:19 581 0.015 0.000 #1 RC=8006 EXE 12:10:19 582 0.047 0.000 #0 RC=8006 ERR rtncd=8006 msg=Invalid datatype specified Invalid Select Item
• For every Select Buffer in Cobol
• You must have a field being selected in SQL • For every Field being selected in SQL • You do NOT necessarily need a Select Buffer • For every Select Buffer in Cobol • The format must match the format of field • The length does not have to match Invalid Select Item
Insert statement • If not referenced, the inserted value is a null • Does not fail on all Database Platforms • Errors out when SQL is executed Cannot Insert Null
12:41:50 184 0.015 0.000 #1 RC=0 COM Stmt=INSERT INTO PS_RFND_EMP_ORG_ID (BUSINESS_UNIT ,BATCH_ID ,EMP_ORG_ID ,REFUND_EMPLID ,REFUND_ORG_CONTACT ,EMPL_ORG_IND) SELECT DISTINCT A.BUSINESS_UNIT ,A.BATCH_ID ,C.REFUND_EMPLID ,C.REFUND_EXT_ORG_ID ,C.REFUND_ORG_CONTACT ,'E' FROM PS_RUN_CNTL_SF A, PS_RUN_CNTL_SF_ITM B, PS_REFND_ITEM_VW C WHERE A.OPRID = :1 AND A.RUN_CNTL_ID = :2 AND A.OPRID = B.OPRID AND A.RUN_CNTL_ID = B.RUN_CNTL_ID AND A.BUSINESS_UNIT = C.BUSINESS_UNIT AND C.SA_ID_TYPE = 'P' AND (C.REFUND_EMPLID = ' ' OR C.REFUND_EMPLID = C.COMMON_ID) AND C.REFUND_EXT_ORG_ID = ' ' AND (C.ITEM_TYPE >= B.ITEM_TYPE_FROM AND C.ITEM_TYPE <= B.ITEM_TYPE_TO) 12:41:50 185 0.016 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=2, value=PS 12:41:50 186 0.015 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=3, value=PAT 12:41:51 187 0.157 0.141 #1 RC=1400 EXE 12:41:51 188 0.031 0.000 #0 RC=1400 ERR rtncd=1400 msg=ORA-01400: cannot insert NULL into ("EMDBO"."PS_RFND_EMP_ORG_ID"."REFUND_EXT_ORG_ID")
SQL does not reference every field on the record
The Solution
• Compare the trace to the stored statement
• If they’re the same: • Check record definition • Make sure that all fields are specified • If not, replicate problem on Demo • If the statement does not agree with trace • Reload stored statements • Review maintenance practices Array issues
with the last cursor • Find array(s) in the cobol program • Generally identified by “Occurs” • May need to identify specific array within program • How to Diagnose Error 153 (Subscript Out of Range or Array Size Exceeded) in a COBOL job [Video] (Doc ID 1153577.1) Max Cursors Exceeded
• Caused by not disconnecting a cursor from a
SQL statement that is used multiple times • Generally is going to be an actual bug • Is not usually replicated as an error on Demo because of a lack of volume • Conditions can be replicated • Trace will prove that cursor is not disconnecting Max Cursor Exceeded
statement executed • From the bottom of the customer’s trace: • Note down the SQL statement and Cursor number • Repeat upwards • When a SQL statement repeats with a different cursor number, that is the problem statement The Solution, Part II
• From the top of a fixed demo trace:
• Find the first occurrence of the problem statement • Write down the cursor number • Find the next occurrence of the problem statement • The problem is replicated if the cursor number is different • You can confirm this by looking for a disconnect on the first cursor number – it should not be found Conclusion
• Powerpoint with narrative is available
• Most issues solved by reloading/recompiling • Work with Support for replicable problems