	/*  
	
	report.sql -	main driver for Collaboration Area Data Integrity Check 

	Copyright 2005, IBM Corporation
	
	Version 2, August 2, 2005
	Version 3, August 3, 2005
	version 4, August 9, 2005
	version 5, August 18, 2005

	Instructions for using this script:

	1. Run the SQL command "select * from coa" in your WPC DB Admin, or sqlplus, window, 
		to see a list of collab areas and their ids.

	2. Find (the name of) the collab area you want to do reporting, i.e. problem detection, for.
		 and write down its id (i.e. the values of its"coa_id" field).

	3. Now do the following:

		a. Run the drop_views.sql script.

		b. Text edit the create_views.sql script, to substitute the desired collaboration area's id, 
		for each of the seven occurrences of the default id value of "84" in that script.

		c. Run the edited create_views.sql script.

		d. Run the procs.sql procedure to define two PL/SQL procedures.

		e. Run this report.sql script.  This will produce a certain report, consisting of one
		"section" per view.  Each section reports the total number of items in that view, and a 
		small random sample of primary keys of items that are in that view.

		f. Run the drop_views.sql script.

	4. Capture the text outputs of all the runs of report.sql, and send those output files to IBM,
		together with the output of the "select * from coa" command.

	END of Instructions.


	NOTES:

	a. In addition to the report produced by this script, the views can be joined to other workflow tables
		to get further information about the state of the collaboration area.  Such potentially useful
		tables include CEH, CAE, CEM, and WEE.  Here are some samples of useful possible queries:

		select ceh.* from s2_primary_key, ceh where ceh_entry_key = s2_primary_key.itm_primary_key order by ceh_entry_key asc;

		select cae.* from s2_item_id, cae where cae_entry_id = s2_item_id.itm_id;

		select cem.* from s1_item_id, cem where cem_src_entry_id = s1_item_id.itm_id;

		select cem.* from s2_item_id, cem where cem_ca_entry_id = s2_item_id.itm_id;

		select cel.* from s2_item_id, cel where cel_entry_id = s2_item_id.itm_id;

		select wee.* from s2_item_id, wee where wee_entry_id = s2_item_id.itm_id;
	
	Note the need to be clear on whether you are dealing with items in the source catalog or items in the
		collaboration area (catalog), and whether a "primary key" or an "item id" view is appropriate.

	b. Optional - You can use the SHOW_ALL_PK_VIEW procedure (defined in procs.sql) to generate a complete list of 
	primary keys of the items in any particular "primary key" view (with respect to any one of the collab areas), one per line.
	For example,

		SHOW_ALL_PK_VIEW( 'V2_PRIMARY_KEY', 'Items in S1,in S2, not in S3' );

	Use SHOW_ALL, of course, before having dropped the relevant views for that collab area.  Be sure you execute
	"set serveroutput on" prior to running this proc in SQL*PLUS, to assure you get your output.

	Note of course that you can get the same information by just doing "select * from V2_PRIMARY_KEY" in SQL*PLUS.


	*/
set serveroutput on size 1000000;
set echo off;
set linesize 120
set heading off
set line 10000
set wrap off
set newpage NONE
BEGIN 
  DBMS_OUTPUT.enable(1000000);
  report_views(1, 100000);
	/* hardwired whichchecks = 1, keystoshow = 100000 */
END; 
/