Session: F14 Introducing your COBOL programs to DB2 version 8. David Churn DST Systems, Inc.

Size: px
Start display at page:

Download "Session: F14 Introducing your COBOL programs to DB2 version 8. David Churn DST Systems, Inc."

Transcription

1 Session: F14 Introducing your COBOL programs to DB2 version 8 David Churn DST Systems, Inc. 16 October :00 10:00 Platform: DB2 for z/os It is supposed to be easy to change your existing programs from single row to multiple row fetch. There are some difficulties involved in this process especially when it is a COBOL program. This presentation will take you through the issues that have been encountered and how DST solved them. Coding examples and some suggested standards will be included. 1

2 The Five Points SQL in COBOL Array handling Using GET DIAGNOSTICS Unit of work Mixing in other SQL features Dzien dobry 2 There are other good feature in v8 that will speed performance but do not impact how COBOL programs are written. Features like scalar full-select and common table expressions have an impact on the program s SQL only. They will not be covered in this presentation. 2

3 Disclaimer The information is presented as is without any warranty either expressed or implied. The use of this information is the client s responsibility. All information in this presentation relates to DB2 Version 8 and COBOL version v3r4. COBOL programs were developed on z/os mainframe using TSO and ISPF. 3 3

4 About DST Systems Leading provider of computer software solutions and services, NYSE listed DST Revenue $2.24 billion 110 million+ shareowner accounts 24,000 MIPS 150 TB DASD 145,000 workstations 462,000 DB2 objects Non-mainframe: 600 servers (DB2, Oracle, Sybase) with 2.3 million objects. 4 If you have ever invested in a mutual fund, have had a prescription filled, or are a cable or satellite television subscriber, you may have already had dealings with our company. DST Systems, Inc. is a publicly traded company (NYSE: DST) with headquarters in Kansas City, MO. Founded in 1969, it employs about 12,000 associates domestically and internationally. The three operating segments - Financial Services, Output Solutions and Customer Management - are further enhanced by DST s advanced technology and e-commerce solutions. 4

5 DST associate mix Applications Development Database Administrators Database Consultants Developers Project Leaders Analysts Programmers hundreds DBA tens DB Consulting ones 5 Our development staff is heavily slanted toward application development. Most enhancements are coded by the applications area to provide new functionality. Application Developers code their own SQL and are responsible for checking the EXPLAIN information. DBAs assist with the enhancements and handle implementing changes to each production system s database. They review new SQL and assist with designing indexes as needed. Database Consulting assists with SQL development on a project basis and assisting our trainers. One of our goals as Database Consultants is to pass along best coding practices to the developers. Database Consultants evaluate new features of DB2 and write the standards for DB2 and COBOL. 5

6 SQL in COBOL This section gives an overview of the new features added to SQL in version 8 that impact how a COBOL program is written. The largest coding change comes from the new multiple row functions for SELECT and INSERT. 6

7 DB2 v8 gives COBOL programs the ability to define larger fields and data inside the program. COB size CURSOR name takes 3 lines using the ISPF editor on TSO. A full size character constant take 7

8 SQL continuation Word/literal occupies column 72 Next line has Hyphen in column 7 Spaces in 8 through 11 Followed by remainder of word/literal Character literal requires a quote EXEC SQL INSERT INTO tbl(column1,colum - n2, column3, column4) VALUES ( , chara - cter literal ) END-EXEC. 8 Even with only 60 characters on a line, it was a rare need to know these rules. With most DB2 obje 8

9 Binary Numbers TRUNC(STD) COMP, COMP-4 and USAGE BINARY are synonyms for truncating binary. Truncation happens when field Receives data from a MOVE Arithmetic result COMP-5 indicates no truncation. S9(4) COMP = to S9(9) COMP = -999,999,999 to +999,999,999 2 bytes 4 bytes S9(4) COMP-5 = to bytes S9(9) COMP-5 = to bytes 9 The COBOL standard states that numeric fields must be truncated to their picture clause. This is sometimes referred to as the odometer effect. A two byte binary field can contain a minimum value of and a maximum of Because the field is defined as PIC S9(4) COMP, COBOL will limit them to 4 digits. DST standard; use COMP-5 for SMALLINT INTEGER VARCHAR lengths Null indicators Note: This applies when the COBOL compiler option TRUNC(STD) is set. It may apply for TRUNC(OPT). It does not apply with TRUNC(BIN). Consult the COBOL for zos Programming Guide for more details. 9

10 Largest numbers Largest COBOL numeric picture S9(31) COMP-3 S9(1)V9(30) COMP-3 z(30)9 z,zzz,zzz,zzz,zzz,zzz,zzz,zzz,zzz,zzz,zz9 Largest DB2 numeric DECIMAL(31,0) COBOL and DB2 math use 31 digits of precision Precompiler parm DEC(31) Compiler parm ARITH(EXTEND) 10 Without using the parms above, the largest COBOL numeric field can be 18 digits and the largest DB2 numeric field can be 15 digits. These smaller parms are faster than the 31 digits parms. The smaller compiler parms are Precompiler DEC(15) Compiler ARITH(COMPAT) If the program has a multi-operation math statement, then the compiler parms also specify the number of digits used for the intermediate results. 10

11 Definitions Array: A group of things arranged in a structured way. In COBOL, a WORKING-STORAGE field with OCCURS. Copybook: predefined COBOL instructions that can be added to a program with either the COPY or EXEC SQL INCLUDE instructions. Host Variable: COBOL field, in either WORKING-STORAGE or LOCAL-STORAGE Host Variable Array: An array that is used in SQL as a host variable. Restartable: Functionality in a program that lets it start over after an error situation. Unit of Work: point where one piece of work is considered done. 11 These define the terms used in this presentation which can have different meaning in another context. For this presentation, table means a DB2 table. 11

12 Multi-row Fetch/Insert Fetch or Insert up to 32,767 rows in one statement Fewer calls to DB2 Use arrays instead of fields Requires more memory Limit the number returned for CICS Request the same or fewer rows than defined in the OCCURS, but not more. Increases program complexity Additional perform loop level More error handling code 12 Our current production COBOL compiler v3r4 expanded the maximum size of an 01 level item to 128Mb while leaving the total size of all working-storage at 128Mb. CICS programs need to manage the amount of memory they are going to use. For batch programs DST defines all columns in a table with the same number of occurrences for each column and null indicator. If a CICS program is only going to use a few columns from a table with hundreds of columns, then we examine how to reduce the extra unused memory. 12

13 If the program requests 100 rows but DB2 returns only 10 rows, the program performs like it requested 10 rows. Some knowledge of the data is needed to evaluate whether to use multi-row FETCH. recommendation = Use Multi-row fetch when a cursor typically returns 4 or more rows. 13

14 Multi-row Fetch SQL syntax Cursor Definition Example DECLARE MEANINGFUL_NAME CURSOR WITH ROWSET POSITIONING FOR SELECT Fetch Example FETCH NEXT ROWSET FROM MEANINGFUL_NAME FOR numeric literal ROWS INTO :hv-array1, :hv-array2 OR FETCH NEXT ROWSET FROM MEANINGFUL_NAME FOR :hv ROWS INTO :hv-array1, :hv-array2 14 When the number of rows is not given multi-row FETCH defaults to 1 row. A program cannot tell DB2 which occurrences to populate in a FETCH. If the program fetches 20 r 14

15 Recommend Multi-row Fetch More than 4 rows per fetch Program is designed for multi-row FETCH Driving cursor defined WITH HOLD Fetch 100 rows Process all rows End unit of work (COMMIT) Entire cursor process is within a single unit of work. Open cursor All rows processed completely Close cursor Start-up array loading cursors 15 Since coding for a multi-row fetch CURSOR is more complex than using a single row CURSOR, w 15

16 Avoid Multi-row Fetch Added complexity without clear savings Program does not have a clear unit of work Burying multi-row functionality inside fetch routine program (1) OPEN FETCH* PROCESS (x) CLOSE UPDATE Check COMMIT FETCH* *=same routine Get more rows? MR-FETCH Give row 16 Fetch time is typically only a small part of the total program time. Even an 55% improvement of 10 Programs that have no clear Logical Unit of Work are more difficult to change. It may even be imp Multi-row SELECT works better when it is designed into the program from the beginning. Burying 16

17 If the program requests 100 rows but DB2 returns only 10 rows, the program performs like it requested 10 rows. Some knowledge of the data is needed to evaluate whether to use multi-row INSERT. recommendation = Use Multi-row insert when a unit-of-work typically inserts 15 or more rows to a table. 17

18 Multi-row Insert Syntax Atomic (default) Severe error (negative SQLCODE) rolls back entire INSERT Stops on first error Easier logic to reposition for restart EXEC SQL INSERT INTO table (column list) VALUES (value list, host variable arrays) FOR :hv ROWS ATOMIC END-EXEC 18 When a program performs a multi-row INSERT using the ATOMIC option, DB2 behaves according An error rolls back the entire INSERT but only the INSERT. DB2 stops checking for errors after it finds the first failed row. There will be only 1 error returned A COBOL program is easier to code restart and reposition logic using the ATOMIC option. 18

19 Multi-row Insert Syntax Not Atomic No rollback Does not stop Restarting can be difficult New SQLCODEs and SQLSTATEs EXEC SQL INSERT INTO table (column list) VALUES (value list, host variable arrays) FOR :hv ROWS NOT ATOMIC CONTINUE ON SQLEXCEPTION END-EXEC 19 When a program performs a multi-row INSERT using the NOT ATOMIC option, DB2 behaves acc DB2 can get multiple errors on the INSERT. The program needs to use GET DIAGNOSTICS to re The code is more complex to restart a program using the NOT ATOMIC option. This type of INSERT is ideal for a program where the only response to an error is to save the row, DB2 will return one of the four SQLCODEs when a program does a multiple row fetch. To determi All successful SQLCODE = +0, SQLSTATE = All successful but warnings SQLCODE = +252, SQLSTATE = At least one (but not all) failed SQLCODE = -253, SQLSTATE = All failed SQLCODE = -254, SQLSTATE =

20 Recommend Multi-row Insert More than 15 rows per insert Many Inserts on single table Inserting is the only process in the program Like load utility without the outage Many inserts within a unit of work 20 recommendation = Use multi-row insert when the primary purpose of the program is to insert--espe Using ATOMIC or NOT ATOMIC options are based on the application logic. To date most have b 20

21 Avoid Multi-row Insert Multiple tables are changed If some/all rows fail (ATOMIC), how does the program back out the other changes related to those rows? If some rows fail (NOT ATOMIC), how does the program back out only the changes related to the failed rows? Do not delay commits for the purpose of building up a host variable array. 21 The program should change other tables after the multi-row insert. So when the program is doing A changes only to successful rows. All this logic will add time to the coding and testing of the program Artificially delaying commits defeats the purpose of commit checks reducing rollback time and co 21

22 Array Handling Multi-row FETCH and INSERT It is not about the SQL. It is about the COBOL! 22

23 Host Variable Arrays SQL references arrays of elements 01 DCL-EMPLOYEE EMPLOYEE-ID PIC S9(5)COMP-3 OCCURS 20 TIMES. 05 COMMENT-TXT OCCURS 20 TIMES. 49 COMMENT-TXT-LEN PIC S9(4) COMP COMMENT-TXT-TEXT PIC X(255). SQL cannot reference a group item array. 01 EMPLOYEE-TABLE. 03 DCL-EMPLOYEE-20 OCCURS 20 TIMES. 05 EMPLOYEE-ID PIC S9(5) COMP COMMENT-TXT. 49 COMMENT-TXT-LEN PIC S9(4) COMP COMMENT-TXT-TEXT PIC X(255). 23 DB2 requires that an array is created for each column used in a SELECT. COBOL has been optimi instructions than the second example. If many fields are defined in the group item (01) then the per DST uses standardized host variable arrays that are created for multi-row functions. If the copybook Other OCCURS sizes can be used but need justification. 23

24 New Multi-row copybooks DCLGEN does not build multi-row copybooks. May require two copy books WHERE clause references single column definitions FETCH INTO references host variable arrays Remember group item lists 24 The standard DCLGEN process included with SPUFI will not generate a table definition where the COBOL fields have the OCCURS clause. Either someone will have to change the generated copybook or someone will need to write something produce the fields to be used in a multi-row function. There may be a need to have both a single row and a multi-row versions of the copybook. SQL WHERE clauses can only reference one type of array. SQL cannot reference one occurrence of an array item. The only COBOL can pass an array is for an IN list. The array has to be defined as follows. Each elementary item is required to have a name even if the value is constant. 01 HV-CUST-INITIALS. 05 HV-INIT1-TX PIC X(3) VALUE SPACE. 05 HV-INIT2-TX PIC X(3) VALUE SPACE. 05 HV-INIT3-TX PIC X(3) VALUE SPACE. 05 HV-INIT4-TX PIC X(3) VALUE SPACE. 24

25 Array Handling Restrictions Use subscripts to access one row from multiple tables COMP vs. COMP-5 (COMP is faster) Updating many indexes is slower than one subscript Cannot use variable length arrays OCCURS DEPENDING ON rejected by precompiler and coprocessor SEARCH and SEARCH ALL will search entire array Must be visible to the SQL precompiler. Cannot use COPY REPLACING Initializing groups of arrays is slower than initializing one array with many fields. 25 There are many different ways to process COBOL arrays. We found that using subscripts was the best way to handle the occurrences with many host variable arrays. We also found that all host variable arrays need to be fixed length even though it makes the SEARCH or SEARCH ALL statements process the entire array. It is faster for COBOL to access an array with an index instead of a subscript. If there are multiple columns inside host variable arrays, then the faster speed is lost to updating multiple indexes instead of one subscript. A program will compile using the same name for multiple indexes as long as it does not reference the name. A program will not compile using an INDEXED BY clause reference another index. Host variable arrays must be visible to the SQL processor. For programs using the precomiler, host variable arrays must be defined in the program or included in the program with EXEC SQL INCLUDE. Programs using the coprocessor can use the COPY and could change the number of rows using the following statement. COPY DATYP REPLACING ==OCCURS 20== BY ==OCCURS 40==. There are fewer Assembler instructions created for initializing one array with multiple fields instead of initializing many host variable arrays. 25

26 COBOL Array Handling SEARCH WHEN clause is limited to one element SEARCH EMPLOYEE-ID [will vary its index] AT END (at end code) WHEN EMPLOYEE-ID (EMPLOYEE-IDX) = ws-employee-id AND WORK-DTE (WORK-DTE-IDX) = ws-work-dte (when found code) END-SEARCH WORK-DTE-IDX will not be incremented by the SEARCH verb. The program compiles successfully, but will produce incorrect results if it requires automatic incrementing. 26 When a program has fetched data into host variable arrays and there is a multiple column key, the p A custom routine must be coded to find the right row. 26

27 Multi-row Fetch data When fetched, null columns do not update the column host variable only the null indicator. ID Name David Jim Smith Churn David John Smith Churn Henry Harry Thompson Jones Henry Kathy Winters Jones Henry Jones Jean Smith Jean Smith Jim Smith Account Null st 8 row FETCH SQLCODE=0 SQLSTATE=00000 SQLERRD(3) = 8 2 nd 8 row FETCH SQLCODE=+100 SQLSTATE=02000 SQLERRD(3)=4 Last 4 rows are carry over from the last FETCH 27 When working with nullable columns it is still important to define and check the null indicator. It would not be good to mix up John Smith s money with David Churn s account. 27

28 Moving VARCHAR For VARCHAR columns, move only the bytes that DB2 populated. Move source (start,length) to destination MOVE text-field OF DCL-xxx-Mnnn (1: text-len OF DCL-XXX-Mnnn) TO Becomes move source (sub) (start:length) to MOVE text-field OF DCL-xxx-Mnnn (sub) (1: text-len OF DCL-XXX-Mnnn (sub) ) TO 28 Like null indicators, a program should move variable length fields for the length that DB2 returned. 28

29 Process loops Old 2000-PROCESS. PERFORM 2100-OPEN-CURSOR PERFORM 2200-FETCH PERFORM UNTIL END-OF-CUR ADD +1 TO FETCH-COUNT PERFORM 6000-WRITE PERFORM 2200-FETCH END-PERFORM PERFORM 2300-CLOSE-CURSOR PERFORM 9600-CHECK-UOW PERFORM 9000-READ 2000-PROCESS. New PERFORM 2100-OPEN-CURSOR PERFORM UNTIL END-OF-CUR PERFORM 2200-FETCH PERFORM 6000-WRITE VARYING EMPLOYEE-SUB FROM +1 by +1 UNTIL EMPLOYEE-SUB > SQLERRD(3) ADD SQLERRD(3) TO FETCH-COUNT END-PERFORM PERFORM 2300-CLOSE-CURSOR PERFORM 9600-CHECK-UOW PERFORM 9000-READ 29 There are two changes to the potential program s logic. 1) The priming FETCH is eliminated. 2) This New example is not the best way to actually code it but is a good way to illustrate the change. 29

30 Multi-row Fetch Caution Non-rowset fetch puts data in first occurrence Mixing rowset and nonrowset fetchs gives unobvious results Fetch more rows than array occurrences gives SQLCODE=+354 SQLSTATE=01668 ID Name David Gordon Jim Mike Suresh Fetch 3 rows Fetch next Fetch 3 rows Fetch 3 rows 6 Thomas 30 When a program only uses multi-row fetch, rows are returned in a predictable fashion. The first Fetch 3 rows returns David, Gordon, and Jim. The second Fetch 3 rows returns Mike, Suresh, and Thomas. When a program adds a FETCH NEXT in between the Fetch 3 rows it give the following results. The first Fetch 3 rows returns David, Gordon, and Jim. The Fetch next returns Gordon. The second Fetch 3 rows returns Jim, Mike, and Suresh. This could cause the program to process the rows for Gordon and Jim twice. 30

31 Using Where Current UPDATE/DELETE WHERE CURRENT... Changes behavior based on last FETCH UPDATE/DELETE WHERE CURRENT OF..FOR ROW x OF ROWSET Update/Deletes a specific row of the rowset Restartable cursors must have an ORDER BY Cursors with ORDER BY cannot use WHERE CURRENT 31 If positioned on a single row (previous fetch was regular), then DB2 updates/deletes single row If positioned on a rowset (previous fetch was ROWSET FOR n ROWS), then DB2 updates/deletes entire set of rows If you mix and match row and rowset fetches in your program, the program could have DB2 accidentally update or delete a rowset instead of a single row! 31

32 Multi-row Insert Feature A non-array column has the same value for ALL rows In the following example, ID and name are simple host variables, not host variable arrays. 05 HV-ID PIC S9(7) COMP-3 VALUE ZERO. 05 HVA-ACCOUNT PIC S9(15) COMP-3 OCCURS 100 TIMES VALUE ZERO. 05 HV-NAME PIC X(100) VALUE SPACES. 05 HVA-AMOUNT PIC S9(11)V99 COMP-3 OCCURS 100 TIMES VALUE ZERO. INSERT INTO TABLE (id, account, name, amount) VALUES (:hv-id, :hva-account, :hv-name, :hva-amount) FOR :hv-num-rows ROWS ATOMIC 32 Multi-row INSERTs do not have to use host variable arrays for every column. If the value for all rows will be the same, then the program could use a non-array COBOL field to save the one value. Like the multi-row FETCH, DB2 always starts with the first occurrence of a host variable array. There is no way to tell DB2 to start with any other occurrence. The program should always set the number of rows inserted. If it tells DB2 insert 4 rows from an array of 8 rows, the first 4 occurrences will be used, the remaining 4 occurrences will be ignored. 32

33 Multi-row Insert Caution Formatting everything Null indicators VARCHAR lengths Number of rows in INSERT Error handling in loops Group moves to or from the host variable arrays 33 Like a single INSERT, verify that all the indicators and lengths are set right in the host variable arra There will be more logic to process errors from inserting multiple rows. Displaying information fro If programs usually move a row s information in one group move, they will have to change to indivi 33

34 Using GET DIAGNOSTICS What happened?!? 34

35 GET DIAGNOSTICS EXEC SQL GET DIAGNOSTICS identifies number of messages each message s SQLCODE and SQLSTATE row number in the host variable array Calling GET DIAGNOSTICS returns an SQLCODE and refreshes the SQLCA 35 It is possible to get multiple warnings as well as an error on one row. Whenever a program uses a multi-row fetch or multi-row insert, it should also use GET DIAGNOSTICS. 35

36 Multi-row Fetch Results Success, SQLCODE=0, SQLSTATE= serious error regular message, SQLCODE=negative GET DIAGNOSTICS will repeat error One to many warnings Overall warning - SQLCODE=+354, SQLSTATE=01668 Multiple warning conditions GET DIAGNOSTICS needed to expose messages Check SQLERRD(3) for rows returned 36 If the program just reports on information in the SQLCA, then it may be hard to determine what happened. SQLCODE=+354, SQLSTATE=01668 A ROWSET FETCH STATEMENT RETURNED ONE OR MORE ROWS OF DATA, WITH ONE OR MORE BIN Explanation: A rowset FETCH statement returned one or more rows of data, however, one or more bind out processing All of the following conditions will cause a multi-row FETCH to return an SQLCODE=+354 Nulls were bypassed for an aggregate function for row 3, 1 message results Date was adjusted occurs for row 9, 1 message results rows 3, 9, and 45 have nulls in a column but the program does not have a null indicator. 1 m 6 errors result! 3 missing null-indicator, 1 nulls bypassed, 1 date adjusted and (1) (th 36

37 For Multi-row Insert ATOMIC Error handling does not change NOT ATOMIC CONTINUE ON SQLEXCEPTION SQLCODE=+252, SQLSTATE=01659, success with warnings SQLCODE=-253, SQLSTATE=22529, one or more rows in error SQLCODE=-254, SQLSTATE=22530, all rows failed EXEC SQL GET DIAGNOSTICS to see the results for each failed row 37 Whether the program gets multiple errors depends on the atomicity of the INSERT. A program can get one error with an ATOMIC multi-row INSERT. A program can get multiple errors with a NOT ATOMIC multi-row INSERT. The SQLCODE passed back in the SQLCA is as useful as the one for multirow FETCH. 37

38 GET DIAGNOSTICS How many errors? EXEC SQL GET DIAGNOSTICS :hv1 = NUMBER,:hv2 = DB2_LAST_ROW,:hv3 = MORE END-EXEC. Specific condition information EXEC SQL GET DIAGNOSTICS CONDITION 1 (or :hv) :GD-RETURNED-SQLSTATE = RETURNED_SQLSTATE, :GD-DB2-RETURNED-SQLCODE = DB2_RETURNED_SQLCODE, :GD-DB2-REASON-CODE = DB2_REASON_CODE, :GD-DB2-ROW-NUMBER = DB2_ROW_NUMBER END-EXEC. 38 GET DIAGNOSTICS can return general information about errors, or information about a specific e specifics on each error. Unlike DSNTIAR this is another call to DB2 and should use SQLCODE ch These are the options that are useful when determining how many errors are present. NUMBER returns an integer the number of conditions identified. DB2_LAST_ROW returns an integer it will contain +100 if the last operation was a multi-row fe MORE returns a Y/N indicator where Y means there was more error information available than cou Specifics The program should use a perform loop to acquire all of the error information. This statement acquires the sqlstate, sqlcode, reason code (sub reason) and row number associated The program can hard code a condition number or can use a host variable. 38

39 DST Usage Copybooks WORKING-STORAGE or LOCAL-STORAGE (copy in the notes) PROCEDURE DIVISION PERFORM 9970-MR-DIAGNOSTICS 01 WS00730 SYNC. 05 GET-DIAGNOSTICS-SQLSTATE PIC X(5) VALUE ZEROS. 05 GD-TOO-MANY-ERRORS PIC X VALUE 'N'. 88 DB2-TOO-MANY-ERRORS VALUE 'Y'. 05 LAST-ROW-SQLCODE PIC S9(9) COMP-5 VALUE ZERO. 88 LAST-ROW-FETCHED VALUE NUM-ERROR-INFO PIC S9(4) COMP VALUE ZERO. 05 ROW-ERROR-INFO OCCURS 500 TIMES. *500 should be sufficient for 100 fetch/insert (subject * To change) 10 ROW-SQLCODE PIC S9(9) COMP-5 VALUE ZERO. 10 ROW-REASON-CDE PIC S9(9) COMP-5 VALUE ZERO. 10 ROW-SQLSTATE PIC X(5) VALUE ZEROS. 10 ROW-NUMBER PIC S9(5) COMP-3 VALUE ZERO. * TEMP WORKING VARIABLES 05 DB2-NUMBER-OF-ERRORS PIC S9(9) COMP-5 VALUE ZERO. 05 DB2-RETURNED-SQLCODE PIC S9(9) COMP-5 VALUE ZERO. 05 DB2-REASON-CODE PIC S9(9) COMP-5 VALUE ZERO. 05 DB2-RETURNED-SQLSTATE PIC X(5) VALUE SPACES. 05 DB2-ROW-NUMBER PIC S9(31) COMP-3 VALUE ZERO. 05 DB2-CONDITION-NUMBER PIC S9(4) COMP-5 VALUE ZERO

40 THIS MACRO IS USED FOR EXEC SQL GET DIAGNOSTICS ERROR * PROCESSING. * * PROGRAM SHOULD PERFORM 9970-MR-DIAGNOSTICS AFTER ANY * MULTI-ROW EXEC SQL STATEMENT RETURNS AN ERROR. * ZC0068 logic 9970-MR-DIAGNOSTICS. Issues GET DIAGNOSTICS to obtain MOVE ZERO The TO number NUM-ERROR-INFO of conditions OF WS EXEC SQL The previous statement s sqlstate GET DIAGNOSTICS Whether more errors occurred than could be :WS00730.DB2-NUMBER-OF-ERRORS reported (copybook limit Is 500 = errors) NUMBER Performs a loop to obtain each error s, :WS00730.LAST-ROW-INDICATOR = DB2_LAST_ROW SQLCODE, :WS00730.GD-TOO-MANY-ERRORS SQLSTATE = MORE END-EXEC. Return code Row number MOVE SQLSTATE Populates TO the GET-DIAGNOSTICS-SQLSTATE array of error information within OF WS00730 the WS00730C copybook IF GET-DIAGNOSTICS-SQLSTATE OF WS00730 = ZEROS * LIMIT RETURNED ERRORS TO 500. IF DB2-NUMBER-OF-ERRORS > +500 SET DB2-TOO-MANY-ERRORS OF WS00730 TO TRUE MOVE +500 TO DB2-NUMBER-OF-ERRORS OF WS00730 END-IF 40 * DB2 BUILDS THE ERROR/CONDITION INFORMATION IN REVERSE ORDER * SO WE WILL BUILD OUR LIST OF INFORMATION BACKWARDS * SO THE ERRORS APPEAR IN THE ORDER THEY OCCURRED. PERFORM VARYING DB2-CONDITION-NUMBER OF WS00730 FROM DB2-NUMBER-OF-ERRORS OF WS00730 BY -1 UNTIL DB2-CONDITION-NUMBER < 1 OR SQLSTATE NOT = ZEROS EXEC SQL GET DIAGNOSTICS CONDITION :WS00730.DB2-CONDITION-NUMBER :WS00730.DB2-RETURNED-SQLSTATE = RETURNED_SQLSTATE,:WS00730.DB2-RETURNED-SQLCODE = DB2_RETURNED_SQLCODE,:WS00730.DB2-REASON-CODE = DB2_REASON_CODE,:WS00730.DB2-ROW-NUMBER = DB2_ROW_NUMBER END-EXEC MOVE SQLSTATE TO GET-DIAGNOSTICS-SQLSTATE OF WS

41 Sample Program Logic Design a process to handle the messages. Consider Can the program continue? What has been rolled back? Multi-row FETCH Multi-row INSERT Atomic vs. Not Atomic Are other processes dependent on this data? Sample code to display gathered messages 41 This logic will display the errors gathered from the include book code. Sample DISPLAY loop PERFORM VARYING DB2-CONDITION-NUMBER OF WS00730 FROM +1 BY +1 UNTIL DB2-CONDITION-NUMBER OF WS00730 > NUM-ERROR-INFO OF WS00730 DISPLAY 'ROW NUMBER : ' ROW-NUMBER OF WS00730 (DB2-CONDITION-NUMBER OF WS00730) DISPLAY 'SQLSTATE : ' ROW-SQLSTATE OF WS00730 (DB2-CONDITION-NUMBER OF WS00730) DISPLAY 'SQLCODE : ' ROW-SQLCODE OF WS00730 (DB2-CONDITION-NUMBER OF WS00730) DISPLAY 'REASON-CDE : ' ROW-REASON-CDE OF WS00730 (DB2-CONDITION-NUMBER OF WS00730) DISPLAY 'ROW CONTENTS : ' UPON CONSOLE (put DISPLAY OF HOST VARIABLE ARRAY CONTENT here) END-PERFORM 41

42 Unit of work 42

43 Restartability Why restart? DB2 rollback costs twice as much as the actual change (insert, update, or delete) Restart concept Where does the unit of work begin and end Determine what triggers an end to a unit of work. Next row from driving cursor Change in control break field value End of file condition Must be designed into the program Do other changes COMMIT before multi-row INSERT? How does the program reposition during restart? 43 Maintainable units of work do not just happen. The associate writing the program has to figure out When the program does not have an apparent unit of work, it is difficult to enhance the program. It If you cannot identify the beginning and ending of the Unit Of Work, you cannot sneak in a multi- If a Unit of Work ends before the program completes a multi-row insert, the insert will beco If a Unit of Work ends before the program completely processes all the rows fetched from a 43

44 Mass Inserts Instead of {Priming Read} PERFORM UNTIL EOF MOVE fields INSERT CHECK COMMIT READ END-PERFORM. Try {Priming READ} PERFORM UNTIL EOF MOVE ZERO TO WS-NUMBER-TO-INSERT PERFORM VARYING x FROM +1 BY +1 UNTIL x > +100 OR EOF MOVE fields TO hv array (x) ADD +1 TO WS-NUMBER-TO-INSERT READ END-PERFORM IF WS-NUMBER-TO-INSERT > ZERO MR-INSERT CHECK COMMIT END-IF END-PERFORM. 44 If the program s process is to insert rows into a table, then the program can COMMIT after filling a 44

45 Multi-row FETCH within a UOW Instead of PERFORM UNTIL EOC FETCH Perform Processrow END-PERFORM. CHECK COMMIT Try PERFORM UNTIL EOC MR-FETCH MOVE SQLERRD(3) TO rows-fetched PERFORM process-row VARYING x FROM +1 BY +1 UNTIL x > rows-fetched END-PERFORM CHECK COMMIT 45 The program should not process more data than DB2 returned. Refer to new example. 45

46 Mixing SQL features INSERT within SELECT SELECT INTO ORDER BY FETCH FIRST SEQUENCE objects XML 46

47 Select from Insert Fewer DB2 calls INSERT and SELECT errors are possible Can be used with multi-row FETCH and INSERT Does not work when an AFTER TRIGGER modifies the changed table. (SQLCODE=-989, SQLSTATE=560C3) Proceed with caution. SELECT col_id, insert_tsp, i_amt FROM FINAL TABLE ( INSERT INTO TRIGGER_TBL (insert_tsp, i_amt) VALUES(current timestamp, :i-amt) 47 Programs have the ability to get the assigned values of columns in the same statement where they are created. Some of the DB2 assigned columns that can be brought back to the program are identity column values, assigned sequence object values, and special register values (like CURRENT TIMESTAMP). When using this type of statement both INSERT errors and SELECT errors are possible, like the following examples. Duplicate key from INSERT (SQLSTATE=23505) Null without a null indicator from the SELECT (SQLSTATE=22002) Unfortunately, this statement is incompatible with some AFTER triggers. When an AFTER trigger, triggered Stored Procedure, or triggered UDF modifies the table that called it, the program gets an SQLCODE Calling GET DIAGNOSTICS reveals the following error. The following text is from DB2 V8 Messages and Codes, pages AFTER TRIGGER trigger-name ATTEMPTED TO MODIFY A ROW IN TABLE table-name THAT WAS INSERTED BY AN INSERT STATEMENT WITHIN A SELECT STATEMENT Explanation: An INSERT statement was specified in the FROM clause of a SELECT statement of a subselect or a SELECT INTO statement, but the underlying target base table of the INSERT has an AFTER trigger defined which modifies the table being inserted. This is disallowed. 47

48 Multi-row Select from Insert Build details (x) Add rows (y) Insert rows (1) Open cursor Fetch x rows Close cursor Audit rows (x) The number of rows and iterations should all be the same! 48 Whenever a program is going to do many inserts and it needs some of the assigned values, it can be written to execute a multi-row INSERT within a multi-row SELECT. To keep the logic simpler, keep the number of rows in the FETCH the same as the number of rows in the INSERT. An ORDER BY INPUT SEQUENCE clause should be used on the CURSOR definition to ensure the host variable array rows match. GET DIAGNOSTICS should also be used to look for INSERT errors with OPEN statement and SELECT errors on the FETCH. 48

49 COBOL arrays example Build all detail columns into host variable arrays 3 calls to DB2 occ ID lmdt lmid col1 col2 col3 seq col AB U MN CD V OP EF W QR GH X ST IJ KL Y Z UV WX Build OPEN FETCH CLOSE Audit becomes ID 100 lmdt 01 lmid AB col1 U col2 11 col3 77 seq 2 col4 MN 49 When to program needs to create a single image of a row it cannot use a group move from the host variable arrays. Instead individual moves from the host variable arrays need to move each column into a one row image. The color show when the individual host variable arrays are populated. Note; ID is an identity column, lmdt is populated with a CURRENT TIMESTAMP, and seq is given a value from a sequence object. 49

50 CURSOR definition DECLARE NEW_EMPLOYEES CURSOR WITH ROWSET POSITIONING FOR SELECT EMPLOYEE_ID, WORK_DTE FROM FINAL TABLE ( INSERT INTO HOURS ( WORK_DTE, WORK_HOURS, APPROVAL_DTE ) VALUES ( CURRENT DATE, :DCLHOURS.WORK-HOURS, NULL ) FOR :WS-INSERT-QTY ROWS ATOMIC ) ORDER BY INPUT SEQUENCE 50 The slide show the actual SQL for populating an example row. Below is an example of the FETCH EXEC SQL FETCH NEXT ROWSET FROM NEW_EMPLOYEES FOR :WS-INSERT-QTY ROWS INTO :DCLHOURS.EMPLOYEE-ID, :DCLHOURS.WORK-DTE END-EXEC. EVALUATE SQLCODE WHEN... WHEN OTHER GET DIAGNOSTICS needed END-EVALUATE 50

51 SELECT INTO with ORDER BY Replace CURSOR with single SELECT Get first or last row from results Continuing after more than one error gives unpredictable results (SQLCODE -811, SQLSTATE=21000) Use this SELECT A.COL1, A.COL2 INTO :WS-COL1, :WS-COL2 FROM TABLEA AS A WHERE ORDER BY A.COL1 FETCH FIRST 1 ROW ONLY Instead of this OPEN FETCH one row CLOSE 51 Another handy feature introduced in version 8 is allowing an ORDER BY clause on a non-cursor SELECT. When used with the FETCH FIRST 1 ROW ONLY, a program does not need a CURSOR process to SELECT a specific row. Using more-than-one-row logic to return first row has always been unpredictable. In test results, we found that DB2 v7 would return the first row found usually in the clustering sequence. In DB2 v8, the second row is returned. 51

52 Sequence Objects work just like Identity columns but are not part of a single table. They can be use those numbers. The syntax above shows how to get values from a sequence object without a SELEC A program can also return the just assigned value of an identity column by using the IDENTITY_VA 52

53 XML COBOL verbs XML PARSE to read a document XML GENERATE to write a document DB2 processes and functions XML extender Save document in one column Use document access definition file (DAD) Parse into a relational table Build XML document Functions to build elements from columns Better functionality in DB There are several choices for building and reading an XML document that relates to DB2 data. COBOL has its own built in function to parse an XML document and build an XML document from an array. DB2 has an automatic way to parse and build XML documents from table items. Programs can also call XML scalar functions on DB2 columns to return the data in XML format. It would take another presentation to cover these options adequately. There is also better functionality in DB2 9 to handle XML data. 53

54 Conclusions Longer names yield better descriptions More COBOL complexity Multi-row INSERT Multi-row FETCH Less COBOL complexity SELECT from INSERT SELECT INTO ORDER BY FETCH FIRST New features Sequence Objects XML 54 Our COBOL programs have access to new features that improve performance. The multi-row functions improve performance while adding some complexity to our programs. The other features improve performance and make the program less complex. Most of the improvements make fewer trips between the program and DB2. DB2 version 8 provides new functionality that makes handling XML data easier and DB2 9 will make it even easier. 54

55 Acknowledgements Special thanks to Mike Todd Dziekuje 55 Special thanks to Mike Todd for providing access to his notes and permission to use the information. 55

56 Session F14 Introducing your COBOL programs to DB2 version 8 David Churn DST Systems, Inc. dcchurn@dstsystems.com Do widzenia 56 56

Session:17701 Multi-Row Processing Coding it in COBOL

Session:17701 Multi-Row Processing Coding it in COBOL Session:17701 Multi-Row Processing Coding it in COBOL Paul Fletcher IBM 7th October 2009 14.15-15.15 Platform:z/OS DB2 V8 promoted Multi-Row processing as one of the major performance enhancements, you

More information

S Coding in COBOL for optimum performance

S Coding in COBOL for optimum performance S16613 - Coding in COBOL for optimum performance Tom Ross IBM March 4, 2015 Insert Custom Session QR if Desired. Title: Coding in COBOL for optimum performance Compiler options Dealing with data types

More information

Section 1. The essence of COBOL programming. Mike Murach & Associates

Section 1. The essence of COBOL programming. Mike Murach & Associates Chapter 1 Introduction to COBOL programming 1 Section 1 The essence of COBOL programming The best way to learn COBOL programming is to start doing it, and that s the approach the chapters in this section

More information

Jim Buck Phone Twitter

Jim Buck Phone Twitter Jim Buck Phone 262-705-2832 jbuck@impowertechnologies.com Twitter - @jbuck_impower www.impowertechnologies.com Presentation Copyright 2017 impowertechnologies.com 5250 & SEU Doesn t work anymore! SEU doesn

More information

Issue 4, March HW([SUHVV Š GDWDEDVHDFFHVV

Issue 4, March HW([SUHVV Š GDWDEDVHDFFHVV 'DWDEDVH$FFHVV Issue 4, March 2002 1HW([SUHVV Š GDWDEDVHDFFHVV Copyright 2002 Micro Focus International Limited. All rights reserved. Micro Focus International Limited has made every effort to ensure that

More information

About these Release Notes. This document contains important information about Pro*COBOL 12c Release 2 (12.2).

About these Release Notes. This document contains important information about Pro*COBOL 12c Release 2 (12.2). Pro*COBOL Release Notes 12c Release 2 (12.2) E85817-01 May 2017 Release Notes About these Release Notes This document contains important information about Pro*COBOL 12c Release 2 (12.2). It contains the

More information

Self-test DB2 for z/os Fundamentals

Self-test DB2 for z/os Fundamentals Self-test DB2 for z/os Fundamentals Document: e1067test.fm 01/04/2017 ABIS Training & Consulting P.O. Box 220 B-3000 Leuven Belgium TRAINING & CONSULTING INTRODUCTION TO THE SELF-TEST DB2 FOR Z/OS FUNDAMENTALS

More information

About these Release Notes

About these Release Notes Pro*C/C++ Release Notes 18c E84346-01 February 2018 Release Notes About these Release Notes This document contains important information about Pro*C/C++ release 18c, version 18.1. It contains the following

More information

Don t Let ICIs put your DB2 applications in the ICU!

Don t Let ICIs put your DB2 applications in the ICU! Don t Let ICIs put your DB2 applications in the ICU! Craig Mullins & Roy Boxwell SEGUS & SOFTWARE ENGINEERING Session Code: V8 On May 25, 2016 at 10:30 Platform: DB2 z/os Photo by Steve from Austin, TX,

More information

Session: E05 Faster FETCH, INSERT, UPDATE (MERGE) DB2 for z/os Multiple Row Processing

Session: E05 Faster FETCH, INSERT, UPDATE (MERGE) DB2 for z/os Multiple Row Processing Session: E05 Faster FETCH, INSERT, UPDATE (MERGE) DB2 for z/os Multiple Row Processing Christopher J. Crone IBM DB2 for z/os Development November 9 th, 2010 11:00 12:00 Platform: DB2 for z/os Presentation

More information

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9 SQL STORED ROUTINES CS121: Relational Databases Fall 2017 Lecture 9 SQL Functions 2 SQL queries can use sophisticated math operations and functions Can compute simple functions, aggregates Can compute

More information

DB2 UDB: Application Programming

DB2 UDB: Application Programming A ABS or ABSVAL... 4:19 Access Path - Determining... 10:8 Access Strategies... 9:3 Additional Facts About Data Types... 5:18 Aliases... 1:13 ALL, ANY, SOME Operator... 3:21 AND... 3:12 Arithmetic Expressions...

More information

Develop a batch DB2 for z/os COBOL application using Rational Developer for System z

Develop a batch DB2 for z/os COBOL application using Rational Developer for System z Develop a batch DB2 for z/os COBOL application using Rational Developer for System z Make use of multiple Eclipse perspectives Skill Level: Intermediate Laurence England (englandl@us.ibm.com) STSM IBM

More information

The information contained in this manual is relevant to end-users, application programmers and system administrators.

The information contained in this manual is relevant to end-users, application programmers and system administrators. August 2002 2002 Preface Purpose This manual describes the GCOS 7 SQL CMA (Client Mode Access) product. This product is intended for anyone who wishes to perform networking operations with databases from

More information

Using OpenESQL to Map COBOL to DBMS Data Types

Using OpenESQL to Map COBOL to DBMS Data Types There is an easy way in Net Express to determine the correct mapping of COBOL data types to the appropriate DBMS's data types. This issue arises frequently and by using the OpenESQL assistant tool the

More information

COBOL - DATABASE INTERFACE

COBOL - DATABASE INTERFACE COBOL - DATABASE INTERFACE http://www.tutorialspoint.com/cobol/cobol_database_interface.htm Copyright tutorialspoint.com As of now, we have learnt the use of files in COBOL. Now, we will discuss how a

More information

About these Release Notes. Documentation Accessibility. New Features in Pro*COBOL

About these Release Notes. Documentation Accessibility. New Features in Pro*COBOL Pro*COBOL Release Notes 12c Release 1 (12.1) E18407-06 April 2013 About these Release Notes This document contains important information about Pro*COBOL 12c Release 1 (12.1). It contains the following

More information

The SQL Procedure Language (SQL PL)

The SQL Procedure Language (SQL PL) The SQL Procedure Language (SQL PL) Tony Andrews Themis Education tandrews@themisinc.com www.themisinc.com Coding a SQL PL Procedure An SQL procedure consists of: CREATE PROCEDURE header BEGIN statement

More information

COBOL performance: Myths and Realities

COBOL performance: Myths and Realities COBOL performance: Myths and Realities Speaker Name: Tom Ross Speaker Company: IBM Date of Presentation: August 10, 2011 Session Number: 9655 Agenda Performance of COBOL compilers - myths and realities

More information

COMP 3400 Mainframe Administration 1

COMP 3400 Mainframe Administration 1 COMP 3400 Mainframe Administration 1 Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 These slides are based in part on materials provided by IBM s Academic Initiative. 1 Databases

More information

COMPUTER EDUCATION TECHNIQUES, INC. (COBOL_QUIZ- 4.8) SA:

COMPUTER EDUCATION TECHNIQUES, INC. (COBOL_QUIZ- 4.8) SA: In order to learn which questions have been answered correctly: 1. Print these pages. 2. Answer the questions. 3. Send this assessment with the answers via: a. FAX to (212) 967-3498. Or b. Mail the answers

More information

Control/SE. Concepts and Facilities Guide. July, Via De Albur Court Suite 100 El Paso, TX P. (800) F.

Control/SE. Concepts and Facilities Guide. July, Via De Albur Court Suite 100 El Paso, TX P. (800) F. Control/SE Concepts and Facilities Guide July, 2015 6416 Via De Albur Court Suite 100 El Paso, TX 79912 P. (800) 252-1400 F. (915) 845-7918 Support@marblecomputer.com www.marblecomputer.com Table of Contents

More information

First lecture of this chapter is in slides (PPT file)

First lecture of this chapter is in slides (PPT file) First lecture of this chapter is in slides (PPT file) Review of referential integrity CREATE TABLE other_table ( b1 INTEGER, c1 INTEGER, PRIMARY KEY (b1, c1) ) CREATE TABLE t ( a integer PRIMARY KEY, b2

More information

IBM DB2 9.7 SQL Procedure Developer.

IBM DB2 9.7 SQL Procedure Developer. IBM 000-545 DB2 9.7 SQL Procedure Developer http://killexams.com/exam-detail/000-545 QUESTION: 105 Click the Exhibit button. Referring to the exhibit, which two statements are correct? (Choose two.) A.

More information

Using SQL & CURSORS In Your Programs

Using SQL & CURSORS In Your Programs Cursored Again! Using SQL & CURSORS In Your Programs Presentation Copyright 2015, Enskill.com Jim Buck Phone 262-705-2832 jbuck@impowertechnologies.com Twitter - @j_buck51 5250 & SEU Doesn t work anymore!

More information

Introduction. Chapter 1:

Introduction. Chapter 1: Introduction Chapter 1: SYS-ED/Computer Education Techniques, Inc. Ch 1: 1 SYS-ED/Computer Education Techniques, Inc. 1:1 Objectives You will learn: New features of. Interface to COBOL and JAVA. Object-oriented

More information

SQL-CMA SQL*XT for ORACLE

SQL-CMA SQL*XT for ORACLE Database Products SQL-CMA SQL*XT for ORACLE GCOS 7 SQL Client Mode Access User's Guide GCOS 7 47 A2 01EL Rev 00 Database Products SQL-CMA SQL*XT for ORACLE GCOS 7 SQL Client Mode Access User's Guide GCOS

More information

DB2 for z/os Stored Procedures Update

DB2 for z/os Stored Procedures Update Robert Catterall, IBM rfcatter@us.ibm.com DB2 for z/os Stored Procedures Update Michigan DB2 Users Group May 15, 2013 Information Management Agenda A brief review of DB2 for z/os stored procedure enhancements

More information

Listing of SQLSTATE values

Listing of SQLSTATE values Listing of values 1 of 28 5/15/2008 11:28 AM Listing of values The tables in this topic provide descriptions of codes that can be returned to applications by DB2 UDB for iseries. The tables include values,

More information

APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 TRUE-FALSE FILL-IN-THE-BLANKS

APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 TRUE-FALSE FILL-IN-THE-BLANKS APPENDIX E SOLUTION TO CHAPTER SELF-TEST CHAPTER 1 2. F The AS/400 family of computers, as with all IBM midrange and mainframe computers, uses the EBCDIC coding system. 3. F Arrival sequence files do not

More information

IBM. Data Sheet. Enterprise COBOL for z/os. Version 6.2

IBM. Data Sheet. Enterprise COBOL for z/os. Version 6.2 Enterprise COBOL for z/os IBM Data Sheet Version 6.2 Enterprise COBOL for z/os IBM Data Sheet Version 6.2 Third edition (January 2018) This edition applies to Version 6 Release 2 of IBM Enterprise COBOL

More information

Embedded SQL /COBOL Programmers Guide. Open Client 15.5

Embedded SQL /COBOL Programmers Guide. Open Client 15.5 Embedded SQL /COBOL Programmers Guide Open Client 15.5 DOCUMENT ID: DC37696-01-1550-02 LAST REVISED: September 2010 Copyright 2010 by Sybase, Inc. All rights reserved. This publication pertains to Sybase

More information

Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A. 14 October :40-17:40 Platform: z/os

Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A. 14 October :40-17:40 Platform: z/os Session: E08 Quit Calling DB2 So Much! Susan Lawson and Dan Luksetich YL&A 14 October 2008 16:40-17:40 Platform: z/os 1 DB2 UDB for z/os 9/15/2008 Disclaimer PLEASE READ THE FOLLOWING NOTICE The information

More information

z/os Learning Center: Introduction to ISPF Unit 2: Editing with ISPF Module 2: Using ISPF Editing Commands

z/os Learning Center: Introduction to ISPF Unit 2: Editing with ISPF Module 2: Using ISPF Editing Commands z/os Learning Center: Introduction to ISPF Unit 2: Editing with ISPF Module 2: Using ISPF Editing Commands Copyright IBM Corp., 2005. All rights reserved. Using ISPF Editing Commands Introduction This

More information

An Introduction to SQL for System i. A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE

An Introduction to SQL for System i. A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE An Introduction to SQL for System i A beginning overview of SQL in System i Navigator and Embedded SQL in RPGLE Quote heard from IBM at a Conference 80% of everything you will need to know three years

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

Exam code: Exam name: Database Fundamentals. Version 16.0 98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

IBM DB2 for z/os Application Developer Certification

IBM DB2 for z/os Application Developer Certification IBM DB2 for z/os Application Developer Certification Professional Certification Exam Copyright 2018 Computer Business International, Inc. www.cbi4you.com 1 What does it involve? IBM DB2 for z/os Application

More information

IBM InfoSphere Classic Federation Server for z/os Version 11 Release 3. System Messages

IBM InfoSphere Classic Federation Server for z/os Version 11 Release 3. System Messages IBM InfoSphere Classic Federation Server for z/os Version 11 Release 3 System Messages IBM InfoSphere Classic Federation Server for z/os Version 11 Release 3 System Messages Note Before using this information

More information

DB2 SQL Tuning Tips for z/os Developers

DB2 SQL Tuning Tips for z/os Developers DB2 SQL Tuning Tips for z/os Developers Tony Andrews IBM Press, Pearson pic Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Cape Town Sydney

More information

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Actual4Test.   Actual4test - actual test exam dumps-pass for IT exams Actual4Test http://www.actual4test.com Actual4test - actual test exam dumps-pass for IT exams Exam : 1z0-144 Title : Oracle Database 11g: Program with PL/SQL Vendor : Oracle Version : DEMO Get Latest &

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Concurrency Control with Locking, Serializability, Deadlocks, Database Recovery Management Lecture 10 zain 1 Basic Recovery Facilities Backup Facilities: provides periodic backup

More information

1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL

1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL CertBus.com 1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL Pass Oracle 1Z0-144 Exam with 100% Guarantee Free Download Real Questions & Answers PDF and VCE file from: 100% Passing Guarantee 100%

More information

IBM i Version 7.2. Database Embedded SQL programming IBM

IBM i Version 7.2. Database Embedded SQL programming IBM IBM i Version 7.2 Database Embedded SQL programming IBM IBM i Version 7.2 Database Embedded SQL programming IBM Note Before using this information and the product it supports, read the information in

More information

Application-enabling features of DB2 for z/os. June Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit

Application-enabling features of DB2 for z/os. June Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit Application-enabling features of DB2 for z/os June 2016 Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit lewisc@us.ibm.com The aim of this presentation To help ensure that you are aware

More information

High Performance Relational Implementation of VSAM Indexed Files

High Performance Relational Implementation of VSAM Indexed Files High Performance Relational Implementation of VSAM Indexed Files Note: this discussion applies to Microsoft SQL Server, Oracle Database and IBM DB2 LUW. The organization of a SQL table with its rows and

More information

enterprise product suite 2.2.2

enterprise product suite 2.2.2 enterprise product suite 2.2.2 WHAT S NEW WHAT S NEW IN THE ENTERPRISE PRODUCT SUITE VERSION 2.2.2 This What s New document covers new features and functions in the latest release of the Micro Focus Product

More information

Database Embedded SQL programming

Database Embedded SQL programming System i Database Embedded SQL programming Version 6 Release 1 System i Database Embedded SQL programming Version 6 Release 1 Note Before using this information and the product it supports, read the information

More information

Index. Symbol function, 391

Index. Symbol function, 391 Index Symbol @@error function, 391 A ABP. See adjacent broker protocol (ABP) ACID (Atomicity, Consistency, Isolation, and Durability), 361 adjacent broker protocol (ABP) certificate authentication, 453

More information

IBM i Version 7.3. Database SQL messages and codes IBM

IBM i Version 7.3. Database SQL messages and codes IBM IBM i Version 7.3 Database SQL messages and codes IBM IBM i Version 7.3 Database SQL messages and codes IBM Note Before using this information and the product it supports, read the information in Notices

More information

Db2 User-Defined Functions

Db2 User-Defined Functions Db2 User-Defined Functions David Simpson Themis Education dsimpson@themisinc.com www.themisinc.com @ThemisDave @ThemisTraining Themis Education Most complete DB2 Curriculum in the industry Offerings include

More information

z/os Db2 Batch Design for High Performance

z/os Db2 Batch Design for High Performance Division of Fresche Solutions z/os Db2 Batch Design for High Performance Introduction Neal Lozins SoftBase Product Manager All tests in this presentation were run on a dedicated zbc12 server We used our

More information

ORACLE: PL/SQL Programming

ORACLE: PL/SQL Programming %ROWTYPE Attribute... 4:23 %ROWTYPE... 2:6 %TYPE... 2:6 %TYPE Attribute... 4:22 A Actual Parameters... 9:7 Actual versus Formal Parameters... 9:7 Aliases... 8:10 Anonymous Blocks... 3:1 Assigning Collection

More information

About these Release Notes

About these Release Notes Pro*COBOL Release Notes 18c E84345-01 February 2018 Release Notes About these Release Notes This document contains important information about Pro*COBOL release 18c, version 18.1. It contains the following

More information

INTRODUCTION TO DATABASE

INTRODUCTION TO DATABASE 1 INTRODUCTION TO DATABASE DATA: Data is a collection of raw facts and figures and is represented in alphabets, digits and special characters format. It is not significant to a business. Data are atomic

More information

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13 CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible

More information

User's Guide c-treeace SQL Explorer

User's Guide c-treeace SQL Explorer User's Guide c-treeace SQL Explorer Contents 1. c-treeace SQL Explorer... 4 1.1 Database Operations... 5 Add Existing Database... 6 Change Database... 7 Create User... 7 New Database... 8 Refresh... 8

More information

IBM InfoSphere Data Replication for IMS for z/os Version 11 Release 3. System Messages

IBM InfoSphere Data Replication for IMS for z/os Version 11 Release 3. System Messages IBM InfoSphere Data Replication for IMS for z/os Version 11 Release 3 System Messages IBM InfoSphere Data Replication for IMS for z/os Version 11 Release 3 System Messages Note Before using this information

More information

FUJITSU Enterprise Postgres Embedded SQL in C and COBOL

FUJITSU Enterprise Postgres Embedded SQL in C and COBOL FUJITSU Enterprise Postgres Embedded SQL in C and COBOL Many companies still run legacy systems that they find to be too large, complex, or vital to be rewritten using newer languages, especially since

More information

Working with DB2 Data Using SQL and XQuery Answers

Working with DB2 Data Using SQL and XQuery Answers Working with DB2 Data Using SQL and XQuery Answers 66. The correct answer is D. When a SELECT statement such as the one shown is executed, the result data set produced will contain all possible combinations

More information

ODD FACTS ABOUT NEW DB2 for z/os SQL

ODD FACTS ABOUT NEW DB2 for z/os SQL ODD FACTS ABOUT NEW DB2 for z/os SQL NEW WAYS OF THINKING ABOUT OLD THINGS + STATIC/DYNAMIC SQL CHANGES, PREDICATE APPLICATION AND LOCKS. LATCHES, CLAIMS, & DRAINS Bonnie K. Baker Bonnie Baker Corporation

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 10 Outline Database Programming: Techniques and Issues Embedded SQL, Dynamic SQL, and SQLJ Database Programming with Function Calls: SQL/CLI and JDBC Database Stored Procedures and SQL/PSM Comparing

More information

Redvers Hashing Algorithm. User Guide. RCHASH Version 2.3

Redvers Hashing Algorithm. User Guide. RCHASH Version 2.3 Redvers Consulting Ltd Redvers Hashing Algorithm User Guide RCHASH Version 2.3 Contents Preface... 3 Introduction... 4 Overview... 5 Installation... 6 Calling RCHASH... 7 Parameters... 7 COMMUNICATION-BLOCK...

More information

Variables and Constants

Variables and Constants HOUR 3 Variables and Constants Programs need a way to store the data they use. Variables and constants offer various ways to work with numbers and other values. In this hour you learn: How to declare and

More information

Generic Attach on Z/OS (or attachment demystified)

Generic Attach on Z/OS (or attachment demystified) Generic Attach on Z/OS (or attachment demystified) Jack Bailey BlueCross BlueShield of South Carolina Jack.bailey@bcbssc.com Session Code: A13 Date and Time of Presentation: May 14, 2010 08:30 AM 09:30

More information

COBOL Unbounded Loops A Diatribe On Their Omission From the COBOL Standard (and a Plea for Understanding)

COBOL Unbounded Loops A Diatribe On Their Omission From the COBOL Standard (and a Plea for Understanding) COBOL Unbounded Loops A Diatribe On Their Omission From the COBOL Standard (and a Plea for Understanding) August 11, 2016 Frank Swarbrick Principal Analyst Mainframe Applications Development FirstBank

More information

See the mechanics of how to do this for a cycle-driven process with a high degree of usability and easy job output management.

See the mechanics of how to do this for a cycle-driven process with a high degree of usability and easy job output management. Abstract: When concurrency is not needed for warehouse applications it is possible to use standard z/os tools to load a Db2 Analytics Accelerator without sample programs or 3rd party tools. See the mechanics

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Programming the Database

Programming the Database Programming the Database Today s Lecture 1. Stored Procedures 2. Functions BBM471 Database Management Systems Dr. Fuat Akal akal@hacettepe.edu.tr 3. Cursors 4. Triggers 5. Dynamic SQL 2 Stored Procedures

More information

1 Preface. 1.1 Summary of contents

1 Preface. 1.1 Summary of contents 1 Preface DRIVE/WINDOWS provides you with access to the database system SESAM/SQL-Server V2 by means of SQL statements. This manual contains a brief description of the exact syntax of the DRIVE SQL statements

More information

Mainframe Developer NO.2/29, South Dhandapani St, Burkit road, T.nagar, Chennai-17. Telephone: Website:

Mainframe Developer NO.2/29, South Dhandapani St, Burkit road, T.nagar, Chennai-17. Telephone: Website: Mainframe Developer Mainframe Developer Training Syllabus: IBM Mainframe Concepts Architecture Input/output Devices JCL Course Syllabus INTRODUCTION TO JCL JOB STATEMENT CLASS PRTY MSGCLASS MSGLEVEL TYPRUN

More information

SYSTEM 2000 Essentials

SYSTEM 2000 Essentials 7 CHAPTER 2 SYSTEM 2000 Essentials Introduction 7 SYSTEM 2000 Software 8 SYSTEM 2000 Databases 8 Database Name 9 Labeling Data 9 Grouping Data 10 Establishing Relationships between Schema Records 10 Logical

More information

Index. NOTE: Boldface numbers indicate illustrations or code listing; t indicates a table. 341

Index. NOTE: Boldface numbers indicate illustrations or code listing; t indicates a table. 341 A access paths, 31 optimizing SQL and, 135, 135 access types, restricting SQL statements, JDBC setup and, 36-37, 37 accessing iseries data from a PC, 280-287, 280 accumulate running totals, 192-197, 193,

More information

COMP 430 Intro. to Database Systems. Encapsulating SQL code

COMP 430 Intro. to Database Systems. Encapsulating SQL code COMP 430 Intro. to Database Systems Encapsulating SQL code Want to bundle SQL into code blocks Like in every other language Encapsulation Abstraction Code reuse Maintenance DB- or application-level? DB:

More information

SUBSCRIPTING A 2-D Table A 3-D Table Laoding a Table The INITIALIZE Statement The Replacing Option...

SUBSCRIPTING A 2-D Table A 3-D Table Laoding a Table The INITIALIZE Statement The Replacing Option... IS SUBSCRIPTING... 1 A 2-D Table... 2 A 3-D Table... 2 Laoding a Table... 4 The INITIALIZE Statement... 5 The Replacing Option... 6 Initialising fixed length Tables... 6 Restrictions on the use of INITIALIZE...

More information

XQ: An XML Query Language Language Reference Manual

XQ: An XML Query Language Language Reference Manual XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple

More information

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 Prof. John Park Based on slides from previous iterations of this course Today s Topics Overview Uses and motivations of hash tables Major concerns with hash

More information

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine. 1 PL/SQL INTRODUCTION SQL does not have procedural capabilities. SQL does not provide the programming techniques of condition checking, looping and branching that is required for data before permanent

More information

Acu4GL COBOL-to-RDBMS Interface

Acu4GL COBOL-to-RDBMS Interface Acu4GL COBOL-to-RDBMS Interface EXECUTIVE OVERVIEW Acu4GL is a patented interface technology designed to bridge the worlds of third-generation COBOL and fourth-generation Structured Query Language (SQL).

More information

Using electronic mail to automate DB2 z/os database copy requests. CMG - 28 e 29 maggio Milano, Roma

Using electronic mail to automate DB2 z/os database copy requests. CMG - 28 e 29 maggio Milano, Roma Using electronic mail to automate DB2 z/os database copy requests CMG - 28 e 29 maggio 2014 - Milano, Roma Agenda 1. UnipolSai Environment 2. UnipolSai needs and problems 3. The initial solution - where

More information

Exact Numeric Data Types

Exact Numeric Data Types SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while

More information

MetaMap Manager User Guide

MetaMap Manager User Guide MetaMap Manager User Guide Release 8.1.3 November 2013 IKAN Solutions N.V. Schaliënhoevedreef 20A B-2800 Mechelen BELGIUM Copyright 2013, IKAN Solutions N.V. No part of this document may be reproduced

More information

Externally Described SQL -- An SQL iquery API

Externally Described SQL -- An SQL iquery API Externally Described SQL -- An SQL iquery API Introduced as a beta test API in SQL iquery v4r7, Externally Described SQL is a simple set of APIs that provide the ability for RPG programmers to leverage

More information

Getting Information from a Table

Getting Information from a Table ch02.fm Page 45 Wednesday, April 14, 1999 2:44 PM Chapter 2 Getting Information from a Table This chapter explains the basic technique of getting the information you want from a table when you do not want

More information

We first learn one useful option of gcc. Copy the following C source file to your

We first learn one useful option of gcc. Copy the following C source file to your Lecture 5 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 5: gcc and gdb tools 10-Oct-2018 Location: Teaching Labs Time: Thursday Instructor: Vlado Keselj Lab 5:

More information

IBM i Version 7.3. Database SQL programming IBM

IBM i Version 7.3. Database SQL programming IBM IBM i Version 7.3 Database SQL programming IBM IBM i Version 7.3 Database SQL programming IBM Note Before using this information and the product it supports, read the information in Notices on page 405.

More information

DB2 UDB: App Programming - Advanced

DB2 UDB: App Programming - Advanced A Access Methods... 8:6 Access Path Selection... 8:6 Access Paths... 5:22 ACQUIRE(ALLOCATE) / RELEASE(DEALLOCATE)... 5:14 ACQUIRE(USE) / RELEASE(DEALLOCATE)... 5:14 Active Log... 9:3 Active Logs - Determining

More information

RDBMS File Access Guide

RDBMS File Access Guide RDBMS File Access Guide Release 8.1.3 November 2013 IKAN Solutions N.V. Schaliënhoevedreef 20A B-2800 Mechelen BELGIUM Copyright 2013, IKAN Solutions N.V. No part of this document may be reproduced or

More information

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL Instructor: Craig Duckett Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL 1 Assignment 3 is due LECTURE 20, Tuesday, June 5 th Database Presentation is due LECTURE 20, Tuesday,

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

S.Q.L. in SQL. David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL

S.Q.L. in SQL. David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL S.Q.L. in SQL David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. What can i do..i can do SQL What are we covering today? SQL Objects (Objects written in SQL and known to the DBMS) File

More information

Westfield DB2 z/os System Management

Westfield DB2 z/os System Management Westfield DB2 z/os System Management Managing the Pain with Stats, Charts, Graphs, & REXX NEODBUG Aug 16, 2012 Mike Smith Westfield Insurance Agenda About Westfield DB2 Workload and Environment Tools and

More information

Moving Data and Printing Information. The Move Statement has The following Format: Move Identifier-1 To Identifier-2. Move Literal-1 To Identifier-2

Moving Data and Printing Information. The Move Statement has The following Format: Move Identifier-1 To Identifier-2. Move Literal-1 To Identifier-2 and Printing Information The Move Statement has The following Format: Format 1 Move Identifier-1 To Identifier-2 Format2 Move Literal-1 To Identifier-2 The Move Statement has the following components Sending

More information

HOW TO DIVIDE: MCC6.NS.2 Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE

HOW TO DIVIDE: MCC6.NS.2 Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE MCC6.NS. Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE Dividend A number that is divided by another number. Divisor A number by which another number

More information

Normalized Relational Database Implementation of VSAM Indexed Files

Normalized Relational Database Implementation of VSAM Indexed Files Normalized Relational Database Implementation of VSAM Indexed Files Note: this discussion applies to Microsoft SQL Server, Oracle Database and IBM DB2 LUW. Impediments to a Normalized VSAM Emulation Database

More information

Using the PowerExchange CallProg Function to Call a User Exit Program

Using the PowerExchange CallProg Function to Call a User Exit Program Using the PowerExchange CallProg Function to Call a User Exit Program 2010 Informatica Abstract This article describes how to use the PowerExchange CallProg function in an expression in a data map record

More information

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives

More information

DB2. Developing SQL and External Routines. DB2 Version 9 SC

DB2. Developing SQL and External Routines. DB2 Version 9 SC DB2 DB2 Version 9 for Linux, UNIX, and Windows Developing SQL and External Routines SC10-4373-00 DB2 DB2 Version 9 for Linux, UNIX, and Windows Developing SQL and External Routines SC10-4373-00 Before

More information

Db2 Query Management Facility Version 12 Release 2. Installing and Managing Db2 QMF for TSO and CICS IBM GC

Db2 Query Management Facility Version 12 Release 2. Installing and Managing Db2 QMF for TSO and CICS IBM GC Db2 Query Management Facility Version 12 Release 2 Installing and Managing Db2 QMF for TSO and CICS IBM GC27-8877-02 Db2 Query Management Facility Version 12 Release 2 Installing and Managing Db2 QMF

More information