Thursday, January 23, 2014

IDUG North America is around the corner

Back from Xams vacation, let me wish everyone a Happy New Year !

As the tradition mandates, I have been taking a few resolutions for 2014, and if you wonder which ones, here you go:
1-      Attend the IDUG conference in Prague
2-      Write a XMLquery without SQL syntax error in less than 10 minutes
3-      Become friend with iterative SQL coding techniques

And since we are at the beginning of the year, it’s time to look at all the great DB2 upcoming events in 2014. As you probably know, IDUG North America is around the corner, it will take place in Phoenix on May 12-16 [more info here]. Unfortunately, I probably won’t make it. I have however looked at the many sessions scheduled, read carefully the description, and selected the ones that matches my interests (and my new year’s resolutions). So here is the top 10 sessions that I recommend (ordered by session’s code) :

1-      A10 DB2 for z/OS: Disaster Recovery for the Rest of Us
2-      B02 How to Optimize a DB2 z/OS Application without any SQL or Program Change?
3-      E03 PARLEZ-VOUS KLINGON - DB2 RECURSION SQL FOR DATABASE MAGICIANS
4-      E07 Going Native: Leveraging DB2 for z/OS SQL Procedures and UDFs
5-      F04 Big Data Disaster Recovery Performance
6-      F06 With the Emergence of Big Data, Where do Relational Technologies Fit?
7-      F08 IBM DB2 Analytics Accelerator - The Performance Revolution Continues
8-      F10 A Big Data Roadmap for the DB2 Professional
9-      G02 The DB2 11 catalog – something new, something old, something changed
10-   G10 Unleash the power of XML retrieval with Xpath and Xquery, are you still with me ?

I must also indicate that I’m gladly surprised that the IDUG Planning Committee (finally!) accepted a z/OS session that really targets “beginners”:
E08 A 50 Cent tour of DB2

Of course, this is only my opinion, and if you have your own suggestions, or if you want to share which sessions you recommend, feel free to comment this article.

Monday, November 25, 2013

List Indexes and IX Columns for a given table

If you ever wanted to see the indexes associated to a given table, the SYSIBM.SYSINDEXES catalog table is for you.
And if you want to see the columns that are indexed, this information is stored in yet another catalog table, SYSIBM.SYSKEYS, but this catalog table does not contain a direct relation to the table.

So, if you want to see all related Indexes and IX Columns for a given table, you must do a JOIN. So far so good, except that you end up with one row, for each columns of the indexes.
That is, if you have a table with 2 indexes, that reference respectively 3 and 5 columns of the table, you will get 8 rows.

   Table  Index  ColName  ColSort
   TB1    IX1    COL1     A
   TB1    IX1    COL2     D
   TB1    IX1    COL3     A
   TB1    IX2    COL1     A
   TB1    IX2    COL5     A
   TB1    IX2    COL2     A
   TB1    IX2    COL3     A
   TB1    IX2    COL7     A

I wanted to simplify the results to get only 2 rows (one per index), that will contain the list of columns, something like:

   Table  Index  Columns
   TB1    IX1    COL1,A,COL2,D,COL3,A
   TB1    IX2    COL1,A,COL5,A,COL2,A,COL3,A,COL7,A

Browsing the internet, I learnt that a special GROUP_CONCAT(expr) function can be used with the GROUP BY syntax, but it does not work with DB2 for z/OS.
Similar results could be archived programmatically, or using a UDF, or … using the new XML functions now available in DB2 for z/OS.
Since I never really played with XML functions, that was a good reason to start!

The following SQL, tested under DB2 version 10, provides the expected results. All the magic happens via the function XMLAGG. The rest (XML2CLOB, CAST, TRIM, or other REPLACEs) is just here to make the results “nicer”.
If you want to use it, just replace the table name (in red), and execute!

  SELECT I.CREATOR, I.TBNAME, I.CREATOR, I.NAME, I.UNIQUERULE,  
  TRIM(L ',' FROM REPLACE(REPLACE(CAST(XML2CLOB(                
  XMLAGG(XMLELEMENT(NAME "C", K.COLNAME, ',', K.ORDERING)       
       ORDER BY K.COLSEQ)                                     
  ) AS VARCHAR(2000)),'<C>',','),'</C>','')) AS "COLUMNS"       
  FROM  SYSIBM.SYSINDEXES I                                     
  INNER JOIN SYSIBM.SYSKEYS K                                   
  ON I.CREATOR = K.IXCREATOR AND I.NAME = K.IXNAME              
  WHERE I.TBNAME = 'PIN_ACCOUNT'                                
  GROUP BY I.TBCREATOR, I.TBNAME, I.CREATOR, I.NAME, I.UNIQUERULE
  ORDER BY I.TBCREATOR, I.TBNAME, I.CREATOR, I.NAME, I.UNIQUERULE ;

Sample output

  CREATOR   TBNAME       CREATOR   NAME      UNIQUERULE  COLUMNS
  $APEPCDB  PIN_ACCOUNT  $APEPCDB  XPEP0180  P           ACCTNUM,A,PIN_COMPANY_ID,A
  $APEPCDB  PIN_ACCOUNT  $APEPCDB  XPEP0280  D           BANK_NUMBER,A


Monday, October 21, 2013

Improve your embedded SQL statements

Review this 3 minute video and discover how you can use the Expert Rules feature of CA Plan Analyzer for DB2 for z/OS to tune your embedded SQL statements. The product can be used by the DB2 Database administrator to analyze existing applications, or by Application Programmers to improve their SQL statements prior their programs reach the production environment.


CA Plan Analyzer for DB2 for z/OS allows you to bypass frustrating and time-consuming methods for plan analysis such as the DB2 EXPLAIN facility, the PLAN_TABLE output or catalog statistics collection. Determine which access paths DB2 has chosen and why with easy-to-understand reports and the ability to customize the individual skill levels.


Friday, October 18, 2013

Discard processing during a Reorg

Review this 3 minutes video and discover how you can use the Discard processing feature of CA Rapid Reorg for DB2 for z/OS to simplify your business workflow, through a simple use case scenario.


CA Rapid Reorg for DB2 for z/OS reorganizes your tablespaces and indexes to alleviate problems caused by disorganized data. CA Rapid Reorg for DB2 for z/OS can reclaim space used by dropped tables, recluster data, remove overflow pointers, reestablish free space, rebalance index trees and reduce the number of levels required.

Thursday, October 17, 2013

csDUG Conference 2013 in Prague


35 attendees from the Czech and Slovak Republics met at the CA Technologies office in Prague on the 8th of October 2013 for a one-day conference. It was the first DB2 user conference in the Czech and Slovak region.



The attendees were a mix of database administrators, systems programmers, application developers and other specialists in the DB2 for z/OS and mainframe area. 

Steen Rasmussen (CA) talking about changes in DB2 10 catalog
The conference focused on the new features in DB2 10 and 11 and IBM DB2 Accelerator. The speakers were experienced DB2 specialists and architects from IBM and CA Technologies. The attendees appreciated the value of the sessions because they received a lot of new information that is related to their job.


MichaƂ Bialecki (IBM), Philippe Dubost (CA), Peter Priehoda (IBM) and Robin Hopper (CA)  
The event was free and sponsored by CA and IBM. There were 5 sessions plus an open and closing session. You can see full agenda at October 8, 2013 – csDUG Conference.

One of the attendees won a free pass for the next IDUG conference in Phoenix, Arizona (USA).

Winner of the free pass for the next IDUG
If you missed the conference this year you will have opportunity to attend next year. As we shape the next event, we would like to hear from you with your preferred city (Prague, Brno, Ostrava or Bratislava), the most convenient time of year for you, and what topics are you interested in. Please post a comment to the blog article. Thank you.








Friday, October 4, 2013

My embedded SQL changed... do I really need to bind again ?

Review this 3 minute video and discover how you can use CA Bind Analyzer for DB2 for z/OS to avoid re-calculating the access path when the changes in an embedded SQL are only “cosmetic”, and what are the benefits of not binding again.


CA Bind Analyzer for DB2 for z/OS helps accelerate the application development lifecycle and decrease unnecessary CPU and I/O resource usage by helping you avoid unnecessary binds.


Tuesday, October 1, 2013

Ensuring That You Can Recover DB2 Data

Many things can go wrong during the recovery process. It is often too late when you find that out during the recovery process.

For example this can happen:
    • An image copy that is required to recover your table space does not exist or is corrupted. 
    • The archive log that is required for recovery is not in BSDS or not cataloged. 
    • The table space selected for recovery is not recoverable because some data has been loaded via a load utility, logging was turned off, and an image copy was not taken after the load. This table space is not recoverable via a recover utility. The same thing can happen when you run REORG without logging. 
CA Recovery Analyzer™ for DB2 for z/OS can help you with that. You can group table spaces and other data objects into strategies using various selection criteria and CA Recovery Analyzer will generate recovery JCL for these objects in an optimal way. During the analysis phase CA Recovery Analyzer verifies that the recovery can really be done by checking the availability of required image copies, archive logs, status of table spaces and verification that the selected recovery point is valid.

If your environment is complex, then you will have many strategies defined and you would like to verify that they are valid and you can recover your data using them.

Strategy Reporting Services in CA Recovery Analyzer are useful for verifying that your strategies do not overlap and that all the spaces you need to recover are included in a recovery strategy. It can also verify that all your strategies are valid and generate the JCL to do the recovery so you will have it ready when you will need it.

If you are already using CA Recovery Analyzer and you have your strategies defined you may benefit from grouping those using Reporting Services and having them analyzed regularly using a batch job.

Here is how you can do it:
    1. Include all of your strategies into one reporting strategy 
    2. Set Generate the Analyze Strategies Error Report, Generate the JCL for each strategy to Y and specify output DSN 
    3. Analyze reporting strategy – it creates JCL to execute the reporting 
    4. Submit the JCL to execute the reporting strategy – to analyze included strategies and generate recovery jobs


Screenshots:









Release 18.0 of CA Recovery Analyzer it will provide an easier way to create a batch job to perform the regular analysis of your recovery strategies.