Presentation is loading. Please wait.

Presentation is loading. Please wait.

Where Do We Start? How Do We Debug? Sources of Debug Information –CICS Transaction Abends –Batch Abend Codes –System Codes –Message Logs –DB2 SQL Codes.

Similar presentations


Presentation on theme: "Where Do We Start? How Do We Debug? Sources of Debug Information –CICS Transaction Abends –Batch Abend Codes –System Codes –Message Logs –DB2 SQL Codes."— Presentation transcript:

1

2 Where Do We Start?

3 How Do We Debug? Sources of Debug Information –CICS Transaction Abends –Batch Abend Codes –System Codes –Message Logs –DB2 SQL Codes

4 Batch Abend Codes –The system reports abends in the form Sxxx Uxxxx. The S literally means "System" The U literally means "User". –One of the most common items mentioned in the table is "subscript out of range". This refers to any access to a COBOL array with a subscript n, where n is the number of OCCURS. If the program stores data in the array with a subscript, memory outside of the array can be destroyed; perhaps causing a later 0C1, 0C4, 0C7 or 04E.

5 Our Agenda SQL Code Basics –Where SQL comes from –SQLCode vs. SQLState –Good & Bad When Should You Check SQL Codes? SQL Code Checking –The code –The cause –Responsible party –Corrective actions Common SQL Codes –000 –100 –-117 –-180 & 181 –-501 –-803 –-805 & -818 –-811 –-904 –-911 Where to Go for Help

6 SQLCA Elements COBOL: 01 SQLCA. 05 SQLCAID PIC X(8). 05 SQLCABC PIC S9(9) COMP-4. 05 SQLCODE PIC S9(9) COMP-4. 05 SQLERRM. 49 SQLERRML PIC S9(4) COMP-4. 49 SQLERRMC PIC X(70). 05 SQLERRP PIC X(8). 05 SQLERRD OCCURS 6 TIMES PIC S9(9) COMP-4. 05 SQLWARN. 10 SQLWARN0 PIC X. 10 SQLWARN1 PIC X. 10 SQLWARN2 PIC X. 10 SQLWARN3 PIC X. 10 SQLWARN4 PIC X. 10 SQLWARN5 PIC X. 10 SQLWARN6 PIC X. 10 SQLWARN7 PIC X. 05 SQLEXT. 10 SQLWARN8 PIC X. 10 SQLWARN9 PIC X. 10 SQLWARNA PIC X. 10 SQLSTATE PIC X(5). An SQLCA is a structure or collection of variables that is updated after each SQL statement executes. An application program that contains executable SQL statements must provide exactly one SQLCA.

7 Get Diagnostics Available in V8 Use for Multi Row Operations Use for support long names Use to retrieve additional information Use the GET DIAGNOSTICS statement to handle multiple SQL errors that might result from the execution of a single SQL statement. First, check SQLSTATE (or SQLCODE) to determine whether diagnostic information should be retrieved by using GET DIAGNOSTICS.

8 What Does It Look Like? EXEC SQL BEGIN DECLARE SECTION; long row_count, num_condns, i; long ret_sqlcode, row_num; char ret_sqlstate[6];... EXEC SQL END DECLARE SECTION;... EXEC SQL INSERT INTO DSN8810.ACT (ACTNO, ACTKWD, ACTDESC) VALUES (:hva1, :hva2, :hva3) FOR 10 ROWS NOT ATOMIC CONTINUE ON SQLEXCEPTION; EXEC SQL GET DIAGNOSTICS :row_count = ROW_COUNT, :num_condns = NUMBER; printf("Number of rows inserted = %d\n", row_count); for (i=1; i<=num_condns; i++) { EXEC SQL GET DIAGNOSTICS CONDITION :i :ret_sqlcode = DB2_RETURNED_SQLCODE, :ret_sqlstate = RETURNED_SQLSTATE, :row_num = DB2_ROW_NUMBER; printf("SQLCODE = %d, SQLSTATE = %s, ROW NUMBER = %d\n", ret_sqlcode, ret_sqlstate, row_num); }

9 SQL Codes vs. SQL State SQLCode –More specific information –Have associated tokens Error Code Resource Type –Can point to object Resource Name SQLState –Std across whole DB2 family z/OS

10 Good & Bad SQL Codes If SQLCODE = 0Execution Was Successful If SQLCODE > 0Execution Was Successful With a Warning If SQLCODE < 0Execution Was Not Successful

11 Typical SQL Code History

12 When to Check SQL Codes Check SQL Codes (cont.) –Misc GET DIAGNOSTICS CALL CONNECT SET Skip SQL Code Checks –BEGIN DECLARE SECTION –DECLARE STATEMENT –DECLARE TABLE –END DECLARE SECTION –INCLUDE –WHENEVER Check SQL Codes –Cursors OPEN FETCH CLOSE –Basic I/O SELECT INSERT UPDATE DELETE –UOW COMMIT ROLLBACK

13 Matching SQLCODEs to SQL  Commonly Handled  Could occur but not commonly handled

14 0 - Successful Call <>0 - Unsuccessful Call Overview of SQL Calls –SQL is transformed to COBOL calls in precompile –Host variables loaded before the call –DB2 Call is executed –SQLCODE gives feedback 0 - OK <0 - failure >0 - warning EXEC SQL ~~~~~ END-EXEC SQLCODE Checks Load Host Variables

15 SQL Code Checking –How’s It Done Handle expected codes before call Call UT97894P-CHECK- SQLCODE after every SQL call Catch handled codes after –Inconsistent SQL Code Checking Leads To breaks program logic weird program errors can extend debugging time SET WS960-HANDLE-NOTFND TO TRUE EXEC SQL ~~~~~~ END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT IF WS960-R-NOTFND PERFORM ~~~~~~ THRU ~~~~~~-EXIT END-IF

16 SQL Code Normal

17 Standard SQL Code Checking SELECT SQL Code 0 <>0 ERROR

18 Not Found

19 Fetch Loop OPEN CURSOR SQL Code FETCH CLOSE SQL Code 0 0 0 <>0 ERROR <0 ERROR <>0 ERROR +100 SQL Code

20 Mismatch SQLState: 42802

21 Column Mismatch Table_A I_CLIE T_CREA I_ACCN_PATN INSERT INTO TABLE_A VALUES (:I-CLIE,:T_CREA,:I_ACCN_PATN ) Alter Table Add Column T_MODF Table_A I_CLIE T_CREA I_ACCN_PATN T_MODF INSERT INTO TABLE_A VALUES (:I-CLIE,:T_CREA,:I_ACCN_PATN ) X #1 #2 #3

22 DB2 Date, Time & Timestamp Errors SQLState: 22007 for both SQL Codes

23 SQL Code: -180 Valid Formats Timestamp yyyy-mm-dd-hh-mm-ss-msmsms yyyy-mm-dd-hh-mm-ss Date mm/dd/yyyy yyyy-mm-dd dd.mm.yyyy Time hh:mm:ss hh:mm hh.mm.ss hh.mm hh:mm AM or hh:mm PM

24 SQL Code: -181 Ranges ComponentValid Range Year 0001 - 9999 Month 1 – 12 Day 1 – 31 (depends upon month & year) Hour 0 - 24 Minute 0 – 59 Second 0 - 59 Microsecond 0 - 9999

25 Bogus FETCH or CLOSE SQLState: 24501

26 Missing SQL Code Checking OPEN CURSOR SQL Code FETCH SQL Code UPDATE CLOSE SQL Code <>0 ERROR <>0 ERROR <0 ERROR 0 0 +100 0 Missing Check A Undetected Rollback on the UPDATE Would Cause the Cursor to Be Closed!

27 DB2 Duplicate Key Errors SQLState: 23505

28 Unique Index Elements SET WS960-DUPKEY TO TRUE EXEC SQL UPDATE VRS97100 SET I_MRI_PATN = NEW-I-MRI-PATN WHERE I_CLIE = :RS100-I-CLIE AND I_ACCN_PATN = :RS100-I-ACCN-PATN END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT … VRS97100 Unique Indexes XRS97100 I_CLIE I_ACCN_PATN XRS97101 I_MRI

29 DB2 Precompiler Timestamp Errors SQLState: 51002 & 51003

30 Consistency Tokens Loadlib DBRMlib

31 DB2 Multiple Rows Errors SQLState: 21000

32 #1 Singleton SELECT (SELECTS 1 Row & Columns) SET WS960-HANDLE-NOTFND TO TRUE EXEC SQL SELECT I_MRI_PATN,N_LAST_PATN INTO :RS100-I-MRI-PATN,:RS100-N-LAST-PATN WHERE I_CLIE = :RS100-I-CLIE AND I_ACCN_PATN = :RS100-I-ACCN-PATN FROM VRS97100 END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT IF WS960-R-NORMAL MOVE RS100-I_MRI_PATN TO…. END-IF –If SQLCODE is OK (=0); 1) SELECTS 1 row –SQLCODE = 0 –Use host variables –If SQLCODE fails (<>0); 1) no rows exist –SQLCODE = +100 –Don’t use host variables! 2) more than 1 row exists –SQLCODE = -811 –Don’t use host variables! 3) other non zero SQLCODE –Don’t use host variables!

33 Good & Bad SQL Codes If SQLCODE = 0Execution Was Successful If SQLCODE > 0Execution Was Successful With a Warning If SQLCODE < 0Execution Was Not Successful

34 #2 Existence Checking (The Most Efficient Way) –If SQLCODE is OK (=0); 1) existence of 1 or more rows –SQLCODE = 0 –If SQLCODE fails (<>0); 1) existence of no rows –SQLCODE = +100 2) other failure –SQLCODE <0 SET WS960-HANDLE-NOTFND TO TRUE EXEC SQL SELECT 1 INTO :WS400-NUMBER FROM VRI97000 WHERE I_CLIE = :RI000-I-CLIE AND I_MRI_PATN = :RI000-I-MRI-PATN FETCH FIRST ROW ONLY END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT IF WS960-R-NOTFND THEN …. END-IF

35 #3 Counting Rows –If SQLCODE is OK (=0); 1) existence of >0 rows –SQLCODE = 0 –INDICATOR-VAR >= 0 –If SQLCODE fails (<>0); 1) existence of no rows –SQLCODE = +100 –INDICATOR-VAR < 0 2) other failure –SQLCODE < 0 SET WS960-HANDLE-NOTFND TO TRUE EXEC SQL SELECT COUNT(*) INTO :WS400-NUMB :WS400-INDICATOR-VARIABLE FROM VCP97160 WHERE I_CLIE = :CP160-I-CLIE AND I_CODE = :CP160-I-CODE END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT IF (WS960-R-NORMAL AND WS400-INDICATOR-VARIABLE >= 0) MOVE WS400-NUMB TO …. END-IF

36 #4 Checking for MULTROWs with a Singleton SELECT If SQLCODE is OK (=0); 1) existence of 1 row –SQLCODE = 0 –If SQLCODE fails (<>0); 1) existence of no rows –SQLCODE = +100 2) existence of +1 rows –SQLCODE=-811 3) other failure –SQLCODE < 0 SET WS960-HANDLE-NOTFND TO TRUE SET WS960-HANDLE-MULTROW TO TRUE EXEC SQL SELECT 1 INTO :WS400-NUMB FROM VCP97160 WHERE I_CLIE = :CP160-I-CLIE AND I_CODE = :CP160-I-CODE END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE- EXIT EVALUATE TRUE WHEN WS960-R-NOTFND …. WHEN WS960-R-MULTROW …. END-EVALUATE

37 #5 Returning a Value From Any Row –If SQLCODE is OK (=0); 1) SELECTS 1 row –SQLCODE = 0 –Use host variables –If SQLCODE fails (<>0); 1) no rows exist –SQLCODE = +100 –Don’t use host variables! 2) other non zero SQLCODE –Don’t use host variables! SET WS960-HANDLE-NOTFND TO TRUE EXEC SQL SELECT C_N_STAN INTO :CP270-C-N-STAN WHERE I_CLIE = :CP270-I-CLIE AND I_N_STAN = :CP270-I-N-STAN AND I_N_STAN_ASSC = :CP270-I-N-STAN-ASSC FROM VRS97100 FETCH FIRST ROW ONLY END-EXEC PERFORM UT97894P-CHECK-SQLCODE THRU UT97894P-CHECK-SQLCODE-EXIT IF WS960-R-NORMAL …. END-IF

38 DB2 Unavailable Resources SQLState: 57011

39 Common Resource Type Codes Type Object Type Object 100 Database 302 Tablespace Page 200 & 202 Tablespace 303 Indexspace Page 201 Indexspace 500 Storage Group 210 Partition 600 EDM Pool 220 Dataset 700 Bufferpool 230 Temporary File 800 Plan 240 Procedure 801 Package 300 Page 901 Sort Storage

40 DB2 Deadlocks & Timeouts SQLState: 40001

41 Other Technical Resources Area Experts DB2 Messages DB2 Codes DB2 Web Site www.ibm.com

42 Questions


Download ppt "Where Do We Start? How Do We Debug? Sources of Debug Information –CICS Transaction Abends –Batch Abend Codes –System Codes –Message Logs –DB2 SQL Codes."

Similar presentations


Ads by Google