db2 stored procedures stored procedures.pdf» applications need not know the details of database...

27
DB2 STORED PROCEDURES »Automating DB2 Stored Procedures in WLM-Environments

Upload: others

Post on 10-Mar-2020

20 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

DB2 STORED PROCEDURES

»Automating DB2 Stored Procedures in WLM-Environments

Page 2: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

1. DB2 Stored Procedures

2. Motivation and goals

3. Realization

4. Summary

5. Questions

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 2

Page 3: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

DB2 Stored Procedures

What is it and how does it work?

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 3

Page 4: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Compiled programs stored at a local or remote DB2 server

» Single piece of code

• Written only once

• Maintained in a single instance

• Callable from several different applications

» Allow static SQL authorization

• Access privileges encapsulated within packages associated with stored procedures

• Grant access to run stored procedure instead of SELECT privilege to the user

» Applications need not know the details of database objects because of encapsulation

DB2 Stored Procedures

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 4

Page 5: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Reduce network traffic

DB2 Stored Procedures

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 5

Page 6: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Must run in WLM-managed address spaces (except native SQL procedures)

• Application environments must be defined to WLM policy

• PROCLIB JCL is needed so that WLM can start the address space(s):

ssnmWLM is the default JCL procedure name

» WLM will start multiple address spaces when needed and allowed

» More than one stored procedure can be assigned to a WLM environment

DB2 Stored Procedures

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 6

Page 7: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

Motivation and goals

What are the recommendations?

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 7

Page 8: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» WLM environments can be refreshed automatically• //AUTOREFR DD DUMMY

must be added to procedure JCL

• May result in duplicate and unnecessary refresh commands

» WLM environments may be stopped due to failures

» Stored procedures may be stopped due to failures

• Indicated by msgDSNX906I:DSNX906I csect-name PROCEDURE OR FUNCTION name TERMINATED ABNORMALLY. THE PROCEDURE HAS BEEN STOPPED. ASID= asid WLM_ENV= wlmenv

Motivation and goals

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 8

Page 9: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» WLM environments should be resumed/refreshed anyway

» No unlimited automatic restarts of stored procedures after failures

• Threshold-checking must be implemented:

no restart when 20 failures in 5 minutes

• Every stored procedure must be checked and handled on its own

» DB2 admins to be notified if stored procedure remains stopped

» Raise a trouble ticket depending on

• Stored procedure name

• WLM environment name

• Customer

• DB2 subsystem name

Motivation and goals

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 9

Page 10: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

Realization

How do we achieve our proposals?

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 10

Page 11: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» REXX C#DB2STP built to be called for msgDSNX906I

1. Extract JOBNAME from message

2. Query SA resource name and command prefix from policy

3. Parse stored procedure name and WLM environment name from message

Realization - REXX

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 11

1

2

3

Page 12: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Handle WLM environments

4. Query status of WLM application environment

Realization - REXX

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 12

4

Page 13: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Build commands to handle WLM environments

5. RESUME, if WLM environment is STOPPED

6. REFRESH, if WLM environment is AVAILABLE

7. Notify automation team on any failures

Realization - REXX

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 13

5

6

7

Page 14: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Handle stored procedures

1. Compose minor resource name for threshold checking, issue CHKTHRES *

2. Inform DB2 admins if critical threshold exceeded

3. Build DB2 command to start stored procedure

4. Notify automation team on any failure

5. Issue built commands in order

Realization - REXX

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 14

1

2

3

4

5

* CHKTHRES allows a maximum of 64 characters as resource name

Page 15: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Handle trouble tickets1. Do a CDEMATCH against dummy message STORPROCTT

– CODE1 contains stored procedure name

– CODE2 contains WLM environment name

– CODE3 contains customer ID

– ENTRY contains DB2 resource name

2. Generate trouble ticket with recipient from value returned if appropriate

Realization - REXX

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 15

1

2

Page 16: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Definitions in class for DB2MSTRs1. Define entry for msgDSNX906I

2. Define C#DB2STP as called routine

Realization - PDB

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 16

1

2

Page 17: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Definitions in class for DB2MSTRs3. Define minor resource STORPROC

4. Set critical threshold to defined values

Realization - PDB

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 17

3

4

Page 18: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Definitions in class for DB2MSTRs5. Define code matching table for trouble ticket generation under dummy message STORPROCTT

– CODE1 = stored procedure name

– CODE2 = WLM environment name

– CODE3 = customer acronym

6. Set recipient aliases as value returned or *IGNORE* to skip trouble ticket generation

Realization - PDB

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 18

5

6

Page 19: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Definitions for recipient aliases read via general subroutine• UET pairs containing all needed information like email addresses

• Can be narrowed down for different customers

Realization - PDB

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 19

Page 20: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Definitions on single instances

• If differing thresholds needed

• If boolean table does not suit the needs on specific resources

Realization - PDB

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 20

Page 21: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Threshold checking must be done for every stored procedure on its own

» Minor resource names unpredictable

• Two fixed keywords: <resource>.STORPROC

• At least one variable keyword: <stored_procedure_name>

» CHKTHRES already designed to handle that

Realization - Runtime

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 21

Page 22: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Threshold entries in ASF queried via DISPERRS

1. Critical threshold exceeded for stored procedure TESTPRC1

2. Stored procedure TESTPRC2 had one hit

Realization - Runtime

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 22

1

2

Page 23: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Threshold exceeded entries also visible via DISPINFO

Realization - Runtime

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 23

Page 24: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

Summary

What did we gain?

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 24

Page 25: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

» Stored procedures are extremely powerful

» Keeping them available is crucial for DB2 overall performance

» Highest flexibility despite static policy definitions

» Using SA‘s facilities eases maintenance and reduces extensive and complex checks

» Visibility through DISPERRS, DISPINFO

» Diversification by leveraging code match tables

» Automatic notification of SMEs or responsible group, documentation via trouble ticket

system

Summary

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 25

Page 26: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

Questions

Want to know more?Dietmar Achim Knodel

Run Mainframe

Wilhelm-Pfitzer-Str. 1

70736 Fellbach

mailto: [email protected]

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 26

Page 27: DB2 STORED PROCEDURES Stored Procedures.pdf» Applications need not know the details of database objects because of encapsulation DB2 Stored Procedures SEITE 4 ∙ DB2 STORED PROCEDURES

Vielen Dank.

Finanz Informatik Technologie Service

Richard-Reitzner-Allee 8

85540 Haar

www.f-i-ts.de

30.04.2019 ∙ Dietmar Achim Knodel∙ DB2 STORED PROCEDURESSEITE 27