0% 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.

Uploaded by

mauro
Copyright
© © All Rights Reserved
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% 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.

Uploaded by

mauro
Copyright
© © All Rights Reserved
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
You are on page 1/ 25

Common Cobol Problem

Diagnosis
Cobol Problem Diagnosis
Agenda

• Bind Variable mis-matches


• Select Buffer issues
• Cannot Insert Null issues
• Array size issues
• Max Cursor Exceeded
Bind Variable Mismatches

• For every Bind setup 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:12:35 575 0.031 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_S_BORFNDT, length=274


12:12:35 576 0.032 0.000 #1 RC=0 COM Stmt=SELECT REFUND_DTTM FROM PS_REFUND_HDR
A WHERE A.BUSINESS_UNIT = :1 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 = ‘A’)
12:12:35 577 0.015 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=5, value=PSUNV
12:12:35 578 0.016 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=9,
value=ADCRM1001
12:12:35 579 0.094 0.000 #0 RC=8001 ERR rtncd=8001 msg=Invalid bind variable
number
Invalid Bind Variable

12:12:35 575 0.031 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_S_BORFNDT, length=274


12:12:35 576 0.032 0.000 #1 RC=0 COM Stmt=SELECT REFUND_DTTM FROM PS_REFUND_HDR
A WHERE A.BUSINESS_UNIT = :1 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 = ‘A’)
12:12:35 577 0.015 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=5, value=PSUNV
12:12:35 578 0.016 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=9,
value=ADCRM1001
12:12:35 579 0.094 0.000 #0 RC=8001 ERR rtncd=8001 msg=Invalid bind variable
number
Invalid Bind Variable

12:12:35 575 0.031 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_S_BORFNDT, length=274


12:12:35 576 0.032 0.000 #1 RC=0 COM Stmt=SELECT REFUND_DTTM FROM PS_REFUND_HDR
A WHERE A.BUSINESS_UNIT = :1 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 = ‘A’)
12:12:35 577 0.015 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=5, value=PSUNV
12:12:35 578 0.016 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=9,
value=ADCRM1001
12:12:35 579 0.094 0.000 #0 RC=8001 ERR rtncd=8001 msg=Invalid bind variable
number
Invalid Datatype

• Occurs when not enough Bind Variable


Values are being setup in Cobol
• Will not error out until the SQL is about to be
executed
Invalid Datatype

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 Datatype

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

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

12:18:28 68 0.031 0.016 #1 RC=0 GETSTMT Stmt=SFPREFND_S_RUNCTL, length=234


12:18:28 69 0.016 0.000 #1 RC=0 COM Stmt=SELECT BUSINESS_UNIT ,REFUND_ITEM_TYPE
,ADDR_USAGE ,REFUND_RUN_TYPE ,EMPLID_ORG_SW ,ALL_PROGRAMS ,ALL_ACCOUNTS ,ALL_TERMS ,RPT_ONLY
,CALC_TUIT_IF_REQ ,SPONSOR_REFUND_OPT FROM PS_RUN_CNTL_SF WHERE OPRID = :1 AND RUN_CNTL_ID = :2
12:18:28 70 0.015 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=2, value=PS
12:18:28 71 0.016 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=3, value=PAT
12:18:28 72 0.016 0.000 #1 RC=0 SSB column=1, type=SQLPBUF, length=5
12:18:28 73 0.015 0.000 #1 RC=0 SSB column=2, type=SQLPBUF, length=12
12:18:28 74 0.016 0.000 #1 RC=0 SSB column=3, type=SQLPBUF, length=12
12:18:28 75 0.015 0.000 #1 RC=0 SSB column=4, type=SQLPBUF, length=10
12:18:28 76 0.032 0.000 #1 RC=0 SSB column=5, type=SQLPBUF, length=1
12:18:28 77 0.015 0.000 #1 RC=0 SSB column=6, type=SQLPBUF, length=1
12:18:28 78 0.016 0.000 #1 RC=0 SSB column=7, type=SQLPBUF, length=1
12:18:28 79 0.016 0.000 #1 RC=0 SSB column=8, type=SQLPBUF, length=1
12:18:28 80 0.015 0.000 #1 RC=0 SSB column=9, type=SQLPBUF, length=1
12:18:28 81 0.016 0.000 #1 RC=0 SSB column=10, type=SQLPBUF, length=1
12:18:28 82 0.031 0.000 #1 RC=0 SSB column=11, type=SQLPBUF, length=1
12:18:28 83 0.016 0.000 #1 RC=8003 SSB column=12, type=SQLPBUF, length=1
12:18:28 84 0.047 0.000 #0 RC=8003 ERR rtncd=8003 msg=Invalid SELECT item number
Invalid Select Item

11 Fields being selected


12:18:28 68 0.031 0.016 #1 RC=0 GETSTMT Stmt=SFPREFND_S_RUNCTL, length=234
12:18:28 69 0.016 0.000 #1 RC=0 COM Stmt=SELECT BUSINESS_UNIT ,REFUND_ITEM_TYPE
,ADDR_USAGE ,REFUND_RUN_TYPE ,EMPLID_ORG_SW ,ALL_PROGRAMS ,ALL_ACCOUNTS ,ALL_TERMS ,RPT_ONLY
,CALC_TUIT_IF_REQ ,SPONSOR_REFUND_OPT FROM PS_RUN_CNTL_SF WHERE OPRID = :1 AND RUN_CNTL_ID = :2
12:18:28 70 0.015 0.000 #1 RC=0 Bind-1, type=SQLPBUF, length=2, value=PS
12:18:28 71 0.016 0.000 #1 RC=0 Bind-2, type=SQLPBUF, length=3, value=PAT
12:18:28 72 0.016 0.000 #1 RC=0 SSB column=1, type=SQLPBUF, length=5
12:18:28 73 0.015 0.000 #1 RC=0 SSB column=2, type=SQLPBUF, length=12
12:18:28 74 0.016 0.000 #1 RC=0 SSB column=3, type=SQLPBUF, length=12
12:18:28 75 0.015 0.000 #1 RC=0 SSB column=4, type=SQLPBUF, length=10
12:18:28 76 0.032 0.000 #1 RC=0 SSB column=5, type=SQLPBUF, length=1
12:18:28 77 0.015 0.000 #1 RC=0 SSB column=6, type=SQLPBUF, length=1
12:18:28 78 0.016 0.000 #1 RC=0 SSB column=7, type=SQLPBUF, length=1
12:18:28 79 0.016 0.000 #1 RC=0 SSB column=8, type=SQLPBUF, length=1
12:18:28 80 0.015 0.000 #1 RC=0 SSB column=9, type=SQLPBUF, length=1
12:18:28 81 0.016 0.000 #1 RC=0 SSB column=10, type=SQLPBUF, length=1
12:18:28 82 0.031 0.000 #1 RC=0 SSB column=11, type=SQLPBUF, length=1
12:18:28 83 0.016 0.000 #1 RC=8003 SSB column=12, type=SQLPBUF, length=1
12:18:28 84 0.047 0.000 #0 RC=8003 ERR rtncd=8003 msg=Invalid SELECT item number

12 Fields being set up


Cannot Insert Null

• All fields in a record must be referenced in an


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 183 0.016 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_I_BONATAA, length=692


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")
Cannot Insert Null

12:41:50 183 0.016 0.000 #1 RC=0 GETSTMT Stmt=SFPREFND_I_BONATAA, length=692


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

• Array size exceeded


• Subscript out of range
• Occurs when more rows are available than
were expected by programmers
• Trace generally will not show the error
message
Array Issues
12:26:36 40526 0.000 0.000 #60 RC=0 EXE
12:26:36 40527 0.000 0.000 #60 RC=0 Fetch
12:26:36 40528 0.000 0.000 #61 RC=0 Bind-1, type=SQLPSLO, length=4, value=13872
12:26:36 40529 0.000 0.000 #61 RC=0 Bind-2, type=SQLPDTE, length=10, value=2000-01-01
12:26:36 40530 0.000 0.000 #61 RC=0 SSB column=1, type=SQLPSLO, length=4
12:26:36 40531 0.000 0.000 #61 RC=0 SSB column=2, type=SQLPDTE, length=10
12:26:36 40532 0.000 0.000 #61 RC=0 SSB column=3, type=SQLPBUF, length=1
12:26:36 40533 0.000 0.000 #61 RC=0 SSB column=4, type=SQLPBUF, length=2
12:26:36 40534 0.000 0.000 #61 RC=0 SSB column=5, type=SQLPBUF, length=1
12:26:36 40535 0.000 0.000 #61 RC=0 SSB column=6, type=SQLPSLO, length=4
12:26:36 40536 0.000 0.000 #61 RC=0 SSB column=7, type=SQLPBUF, length=1
12:26:36 40537 0.000 0.000 #61 RC=0 EXE
12:26:36 40538 0.000 0.000 #61 RC=0 Fetch
12:26:36 40539 0.000 0.000 #61 RC=1 Fetch
12:26:36 40540 0.000 0.000 #60 RC=0 Fetch
The Solution

• Identify the name of the statement associated


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

15:04:36 19516 0.000 0.000 #254 RC=0 Connect=SAACEP/sa/?


15:04:36 19517 0.000 0.000 #254 RC=0 GETSTMT Stmt=SFPCFHLP_S_CENSUSS, length=136
15:04:36 19518 0.000 0.000 #254 RC=0 COM Stmt=SELECT CENSUS_DT, USE_DYN_CLASS_DATE FROM PS_SESSION_TBL WHERE
INSTITUTION = :1 AND ACAD_CAREER = :2 AND STRM = :3 AND SESSION_CODE = :4
15:04:36 19519 0.000 0.000 #254 RC=0 Bind-1, type=SQLPBUF, length=5, value=ANUID
15:04:36 19520 0.000 0.000 #254 RC=0 Bind-2, type=SQLPBUF, length=4, value=PGRD
15:04:36 19521 0.000 0.000 #254 RC=0 Bind-3, type=SQLPBUF, length=4, value=1760
15:04:36 19522 0.000 0.000 #254 RC=0 Bind-4, type=SQLPBUF, length=1, value=1
15:04:36 19523 0.000 0.000 #254 RC=0 SSB column=1, type=SQLPDTE, length=10
15:04:36 19524 0.000 0.000 #254 RC=0 SSB column=2, type=SQLPBUF, length=1
15:04:36 19525 0.000 0.000 #254 RC=0 EXE
15:04:36 19526 0.000 0.000 #254 RC=0 Fetch
15:04:36 19527 0.016 0.000 #254 RC=0 EPO error pos=0
15:04:36 19528 0.078 0.000 #254 RC=0 Rollback
15:04:36 19529 0.000
15:04:36 19530 0.000
0.000 #254 RC=0 Disconnect
0.000 #253 RC=0 EPO error pos=0 Repeats 254 Cursors
15:04:36 19531 0.000 0.000 #253 RC=0 Rollback
15:04:36 19532 0.000 0.000 #253 RC=0 Disconnect
The Solution, Part I

• The problem SQL statement is NOT the last


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

You might also like