Tuesday, December 30, 2014

monitor DB2 reorg with db2pd + awk

If you want to monitor the progress of reorgs running in db2, you can use the following command:

db2pd -db tmdb -reorgs | awk '$5=="n/a"&&$4!="n/a" {print $2 " : " $9/$10*100 " %"}'

output is:

TABLENAME : Percentage complete %


Thursday, May 8, 2014

Stored Procedure wlm_set_client_info gives error sql1131n

We are using the stored procedure wlm_set_client_info to identify which reports are running on our datawarehouse, we've setup Microstrategy following the guide on the DB2 best practices website:
DB2BP_WLM_Setting_Client_Info_Fields.pdf

This allows us to link the executing sql with a report on the microstrategy level,
facilitating the communication between the Microstrategy administrator and the DBA team,
this works for other multier environments as well, and is very useful in my opinion,

The issue described in the subject occurred when our system engineer was setting up a drp method for our datawarehouse,
during this time our file systems were unmounted and remounted,

after this intervention our microstrategy administrator complained that reports no longer executed and gave the error message when the call to the stored procedure wlm_set_client_info was mad by Microstrategy,

after some investigation we discovered that not only this stored procedure , but ALL stored procedures showed the same error message, SQL1131N
SQL1131N error code in the information center

in the end we discovered that during the system intervention, the system engineer assumed that the fenced user of our db2 instance was not used, so he removed this user,
db2 started and worked correctly except for the stored procedures that were to be executed by the fenced user,

once the fenced user was created again with the correct UID,
the system behaved normally as before.



Wednesday, May 7, 2014

Check if the next value of a Identity column is lower than max value of that column in table on DB2/Z

compare result of query:
select a.DCREATOR as tabschema,a.dname as tabname, a.dcolname as column_name,a.dtype as TYPE_OF_DEPENCY,maxassignedval as last_value from sysibm.syssequencesdep  a join sysibm.syssequences b on a.bsequenceid=b.sequenceid where dtype='I'

 with:

select max(<column name>) from <table schema>.<table name>;

If the first query it's value is lower than the second value, this could indicate that you will encounter primary key conflict in this column