What are all the government/bank holiday dates in the US in 2012? You can tell this by grabbing a calendar or doing a search on the net. What if you need this information in a program? What if you need this information for year 2013, 2014 etc.? Mr Martin Dunkel has written a REXX and he has graciously agreed to share his code with us all. The code is available in the link below. Please feel free to make a copy of it and change as needed. I've tested this code as it is. His contact info is available in the REXX, in case you have any questions that I cannot answer.
All credit goes to Mr Martin Dunkel !! Thank You Mr Dunkel.
Here is the code: https://docs.google.com/open?id=0B4whLShAZsgERW1vZmlVSDQ0WXc
Technical Tips including DB2 z/OS, DB2 LUW, COBOL, JCL, VSAM, CICS, 3rd party vendor tools (BMC, CA, IBM, Macro4, etc.)
Wednesday, December 5, 2012
Saturday, January 21, 2012
DB2 for zOS Index on Expression
DB2 for z/OS version 9 brought in a new feature called "Index on Expression". Yes, you can create indexes on frequently used expressions in your queries. For example, if you often do a SELECT FIRST_NAME WHERE UPPER(LAST_NAME) = 'SMITH', then creating an index on UPPER(LAST_NAME) will be useful.
Until V8, you can create index on just columns, not on expressions/functions etc. So, you would have created an index on LAST_NAME, but DB2 would have ignored it because when you use a function on a column, DB2 ignores index access. But starting in V9, you can create an index on UPPER(LAST_NAME) and DB2 will use this index.
Now, to the tricky part ...
I tried to create an index on UPPER(LAST_NAME), DB2 complained that I need to specify 'locale' name. After reading a little bit about 'locale names', I specified UPPER(LAST_NAME, 'En_US') and DB2 happily created the index. I also ran runstats on the table. However, when I did an explain on the query SELECT FIRST_NAME WHERE UPPER(LAST_NAME) = 'SMITH', DB2 didn't seem to pick up the newly created index. That puzzled me.
After reading a little further, I found that I need to specify the same 'locale' in the query too. After specifying the 'locale', I did an explain and DB2 picked up the index. This is the modified query:
SELECT FIRST_NAME WHERE UPPER(LAST_NAME, 'EN_US') = 'SMITH'
Keywords: DB2, z/OS, Index, Expression, Upper, Locale, function
Subscribe to:
Posts (Atom)