On this page: Target audience: Users of the SQL Analyzer extension. |
Summary: this page provides instructions for those that would like to transition from using the "out-of-the box" DB2 Analyzer provided in CAST AIP to the SQL Analyzer extension. |
If you have been actively analyzing DB2 (z/OS or UDB) with the DB2 Analyzer (provided out-of-the-box in CAST AIP) you can transition to using the SQL Analyzer extension to analyze your DB2 source code. The process of transitioning is described in this page.
Note that it is only possible to analyze DB2 when using the SQL Analyzer extension ≥ 2.x. |
Take a snapshot of the existing Application prior to making any further changes.
CSSBackup.exe -schema db2_udb_local -password CastAIP -file c:\temp\DB2\db2_udb_local.cssdmp -log c:\temp\DB2\db2_udb_local.log CSSBackup.exe -schema db2_udb_central -password CastAIP -file c:\temp\DB2\db2_udb_central.cssdmp -log c:\temp\DB2\db2_udb_central.log CSSBackup.exe -schema db2_udb_measure -password CastAIP -file c:\temp\DB2\db2_udb_measure.cssdmp -log c:\temp\DB2\\db2_udb_measure.log CSSBackup.exe -schema db2_udb_mngt -password CastAIP -file c:\temp\DB2\db2_udb_mngt.cssdmp -log c:\temp\DB2\\db2_udb_mngt.log |
Before proceeding, check your results and grades using the CAST dashboards. Example below show a DB2 UDB analysis:
Portfolio
Click to enlarge:
Quality and size evolution
Click to enlarge:
Violated rules by technology
Click to enlarge:
Please see:
Note that you need to install the extension into the CAST AIP schemas that you were using previously to host your Application containing the DB2 analysis results. |
This step is only relevant for those analyzing DB2 UDB online. |
Use the following query, run against your CAST AIP Management Service schema, to retrieve the connection details to the live DB2 UDB databases that are used during the analysis with the DB2 Analyzer (provided out-of-the-box in CAST AIP). This information can be reused when extracting the DDL for use with the SQL Analyzer extension:
select partdetails.Object_Name PackageName, UserName, Host, Port, DbName, projdetails.Object_Name SchemaName from (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DatabaseServerParticipatingDB2') part, (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DB2UDBSourceCodeRepository') proj, CMS_INF_PARTP_DBUDB partdetails, CMS_UDB_Project projdetails where part.Field_Value like proj.Field_Value || '%' and partdetails.Object_ID = part.Object_ID and proj.Object_ID = projdetails.Resource_ID order by Host, DbName, SchemaName |
select partdetails.Object_Name PackageName, UserName, Host, Port, DbName, projdetails.Object_Name SchemaName from (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DatabaseServerParticipatingDB2') part, (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DB2UDBSourceCodeRepository') proj, CMS_INF_PARTP_DBUDB partdetails, CMS_UDB_Project projdetails where part.Field_Value like proj.Field_Value + '%' and partdetails.Object_ID = part.Object_ID and proj.Object_ID = projdetails.Resource_ID order by Host, DbName, SchemaName |
The output of the above queries will result in similar output
CAST DMT Package Name | DB2 login | Host name | Host port | Database Name | Schema Name |
---|---|---|---|---|---|
UDB_Package | db2admin | UDBSERVER | 50000 | TEST | CASTPUBS |
This step explains how to generate the DDL from the DB2 database that will be fed into the CAST Delivery Manager Tool for analysis with the SQL Analyzer extension.
|
The tool used to achieve this is the db2look tool provided with the DB2 UDB server (see the full documentation for the tool here: https://www.ibm.com/support/knowledgecenter/en/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002051.html). This example will generate an .SQL file containing the DDL for the CASTPUBS schema on the TEST database accessed with the db2admin/db2admin credentials:
db2look -d TEST -z CASTPUBS -i db2admin -w db2admin -e -o E:\tmp\SQL_DB2\TEST_CASTPUBS.sql |
You can view example DDL output generated by db2look in the attached files:
This section is only relevant for those analyzing DB2 UDB online. |
If you need to generate DDL for multiple schemas use the following query (run against your CAST AIP Management Service schema) to automatically generate commands that can be used with the db2look tool:
select 'db2look -d ' || DbName || ' -z ' || projdetails.Object_Name || ' -i ' || UserName || ' -w db2admin -e -o ' || DbName || '_' || projdetails.Object_Name || '_DDL.sql' batch from (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DatabaseServerParticipatingDB2') part, (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DB2UDBSourceCodeRepository') proj, CMS_INF_PARTP_DBUDB partdetails, CMS_UDB_Project projdetails where part.Field_Value like proj.Field_Value || '%' and partdetails.Object_ID = part.Object_ID and proj.Object_ID = projdetails.Resource_ID order by batch |
select 'db2look -d ' + DbName + ' -z '+ projdetails.Object_Name + ' -i ' + UserName + ' -w db2admin -e -o ' + DbName + '_' + projdetails.Object_Name + '_DDL.sql' batch from (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DatabaseServerParticipatingDB2') part, (select * from CMS_DynamicFields where Entity_GUID = 'dbtwoserver.DB2UDBSourceCodeRepository') proj, CMS_INF_PARTP_DBUDB partdetails, CMS_UDB_Project projdetails where part.Field_Value like proj.Field_Value + '%' and partdetails.Object_ID = part.Object_ID and proj.Object_ID = projdetails.Resource_ID order by batch |
The result of the above querieswill be as follows - one db2look command per schema on the target DB2 server. Each command will output the specified schema as DDL into one .SQL file:
db2look -d TEST -z CASTPUBS -i db2admin -w db2admin -e -o E:\tmp\SQL_DB2\CASTPUBS.sql db2look -d TEST -z DB2_DIAGS -i db2admin -w db2admin -e -o E:\tmp\SQL_DB2\DB2_DIAGS.sql |
Take two new snapshots (ensure that you run an analysis as well) and then check the results in the CAST dashboards:
Portfolio
Click to enlarge:
Quality and size evolution
Click to enlarge:
Note that new Quality Rules will be calculated for the SQL Analyzer extension in comparison to the online DB2 analyzer:
|