set echo off
Rem  Copyright (c) 1998 by U.S. Environmental Protection Agency 
Rem    NAME
Rem      analyze.sql - <one-line expansion of the name>
Rem    DESCRIPTION
Rem      <short description of component this file declares/defines>
Rem    RETURNS
Rem 
Rem    NOTES
Rem      <other useful comments, qualifications, etc.>
Rem    MODIFIED   (MM/DD/YY)
Rem     kchristian   07/01/98 -  comment out vms specific host command 
Rem     kchristian   07/01/98 -  Creation 
Rem     kchristian   07/01/98 -  Creation 
rem 
rem $Header: analyze.sql,v 1.0 1998/07/01 12:00:00 KCHRISTIAN Exp $ 
rem 
-- connect storet1/storet1
set termout on
set echo on
-- This Script (del_org.sql) Removes ALL Org IDs Rows from Schema Owner 
-- SQL Plus Environment Variables
set echo off
set verify off
set feedback off
set termout on
set time on
set timing off
set heading off
set trimspool on
set linesize 300
set pagesize 0
--
UNDEFINE your_org
UNDEFINE dba_user
UNDEFINE schema_user
UNDEFINE drowssapu 
UNDEFINE connectstring 
--
--
rem 	To assign values for the following Requested Parameters --- Please Delete "REM" the Following 5 lines: "DEFINE" Statements 
rem 	To assign values for the following Requested Parameters --- Please Delete "REM" the Following 5 lines: "DEFINE" Statements 
rem 	To assign values for the following Requested Parameters --- Please Delete "REM" the Following 5 lines: "DEFINE" Statements 
--
REM				DEFINE	dba_user 	= SYSTEM
REM				DEFINE	schema_user 	= STORET1
REM				DEFINE	drowssapu 	= storet
REM				DEFINE	connectstring 	= 2:stor
--
--
rem 	To be Prompted for the following Requested Parameters --- Please remark "REM" the Following 5 lines: "DEFINE" Statements 
rem 	To be Prompted for the following Requested Parameters --- Please remark "REM" the Following 5 lines: "DEFINE" Statements 
rem 	To be Prompted for the following Requested Parameters --- Please remark "REM" the Following 5 lines: "DEFINE" Statements 
--
--
prompt Referential Integrity Check Script:
prompt 
prompt Prerequiste Info: Database Logon
prompt 
prompt Enter database alias / connect string (ie. 2:stor): 
set termout off
				DEFINE	connectstring = @&connectstring
set termout on
prompt 
prompt Enter database username with DBA privileges (SYSTEM): 
set termout off
				DEFINE	dba_user = &dba_user
set termout on
prompt 
prompt Enter password for &dba_user: 
set termout off
				DEFINE	drowssapu = &drowssapu
set termout on
prompt 
prompt Schema Evaluation Info: DATA Schema Owner
prompt Enter Database Username/Schema, which owns the DATA (STORET1): 
prompt 
set termout off
				DEFINE	schema_user = &schema_user
set termout on
prompt 
prompt Enter Target ORG_ID in "UPPER CASE", to mark DATA for DELETION (DEMOTEST): 
prompt 
set termout off
				DEFINE	your_org = &your_org
set termout on
prompt ***
prompt **
prompt *
prompt Review the following Requested Parameters 
prompt Organization ID marked for DELETION: 			&your_org
prompt Database User / Schema Evaluation: 			&schema_user
prompt Database Username with DBA privileges: 			&dba_user
-- prompt Password for Username &dba_user: 			&drowssapu
prompt Database Alias / Connect String: 			&connectstring
--
-- validate org_id
prompt 
prompt Searching for Target ORG_ID (&your_org): 
select 'ERROR' "ERROR"
from &schema_user..tsmorgan
where not exists (select 'x'
                   from &schema_user..tsmorgan where org_id=upper('&YOUR_ORG'));
prompt ----------------------------------------. 
prompt 
select 'Organization ID = (&your_org) was NOT FOUND...'||chr(10)||'Please Press `CTRL-C` to abort. ' "ERROR"
from &schema_user..tsmorgan
where not exists (select 'x'
                   from &schema_user..tsmorgan where org_id=upper('&YOUR_ORG'));
--
ACCEPT CONTINUE CHAR FORMAT A1 PROMPT 'If CORRECT, Press <ENTER> to Test Logon Information. (CTRL-C to abort): '
prompt **** Testing connect privilege for &dba_user
prompt CONNECTING as user &dba_user ...
connect &dba_user/&drowssapu&connectstring
show user
show errors
prompt *
prompt **
prompt ***

-- accept dba_user prompt 'Enter database username with DBA privileges (SYSTEM): '
-- accept connectstring prompt 'Enter database connect string :'
-- prompt 'Enter password for &dba_user@&connectstring:'
-- connect &dba_user@&connectstring
-- accept schema_user prompt 'Enter Database Username/Schema, which owns the DATA (STORET1): '
-- accept your_org char format A8 prompt 'Enter ORG_ID(UPPER CASE) to DELETE from all tables (CTRL-C to abort): '

PROMPT Your SQL*Plus Session is currently connected to Database as USER/SCHEMA... 
show user
PROMPT Script Log File: c:\del_org_&YOUR_ORG..log
select * from v$instance;
PROMPT This Script (del_org.sql) Removes All DATA for (&YOUR_ORG) Org IDs Rows from Schema Owner &schema_user
ACCEPT CONTINUE CHAR FORMAT A1 PROMPT 'Press <ENTER> To Continue an EXECUTE ..last chance.. (CTRL-C to abort): '

set verify on
set feedback on
set echo ON

spool c:\del_org_&YOUR_ORG..log

PROMPT  Removing &YOUR_ORG's Rows from table TSMADDR ,  Please Wait...
 Delete From &schema_user..TSMADDR WHERE TSMADDR_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMALP ,  Please Wait...
 Delete From &schema_user..TSMALP WHERE TSMALP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMCHKPT ,  Please Wait...
 Delete From &schema_user..TSMCHKPT WHERE LAST_PROCESSED_ORG1='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMCPORG ,  Please Wait...
 Delete From &schema_user..TSMCPORG WHERE TSMCPORG_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMCSNG ,  Please Wait...
 Delete From &schema_user..TSMCSNG WHERE TSMINTVL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMEADDR ,  Please Wait...
 Delete From &schema_user..TSMEADDR WHERE TSMEADDR_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMEISN ,  Please Wait...
 Delete From &schema_user..TSMEISN WHERE TSMEISN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSMEISN ,  Please Wait...
--  Delete From &schema_user..TSMEISN WHERE TSMEISN_ORG_ID='ZZZZZZZZ' ;
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMERS ,  Please Wait...
 Delete From &schema_user..TSMERS WHERE TSMERS_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMESTLC ,  Please Wait...
 Delete From &schema_user..TSMESTLC WHERE TSMALP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMFCLTY ,  Please Wait...
 Delete From &schema_user..TSMFCLTY WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMFILL ,  Please Wait...
 Delete From &schema_user..TSMFILL WHERE TSMINTVL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMFSA ,  Please Wait...
 Delete From &schema_user..TSMFSA WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMGLL ,  Please Wait...
 Delete From &schema_user..TSMGLL WHERE TSMALP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMGNTXT ,  Please Wait...
 Delete From &schema_user..TSMGNTXT WHERE TSMGNTXT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSMGNTXT ,  Please Wait...
--  Delete From &schema_user..TSMGNTXT WHERE TSMGNTXT_ORG_ID='ZZZZZZZZ' ;
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMHOLE ,  Please Wait...
 Delete From &schema_user..TSMHOLE WHERE TSMINTVL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMIGUA ,  Please Wait...
 Delete From &schema_user..TSMIGUA WHERE TSMIGUA_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMINTVL ,  Please Wait...
 Delete From &schema_user..TSMINTVL WHERE TSMINTVL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMLOG ,  Please Wait...
 Delete From &schema_user..TSMLOG WHERE TSMLOG_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMOCNLC ,  Please Wait...
 Delete From &schema_user..TSMOCNLC WHERE TSMALP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMOPNG ,  Please Wait...
 Delete From &schema_user..TSMOPNG WHERE TSMINTVL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

-- Delete From &schema_user..TSMORGAN ;
-- PROMPT  Removing &YOUR_ORG's Rows from table TSMORGAN ,  Please Wait...
--  Delete From &schema_user..TSMORGAN WHERE ORG_ID='ZZZZZZZZ' ;
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMPCOA ,  Please Wait...
 Delete From &schema_user..TSMPCOA WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPERSN ,  Please Wait...
 Delete From &schema_user..TSMPERSN WHERE TSMPERSN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPIPE ,  Please Wait...
 Delete From &schema_user..TSMPIPE WHERE TSMPIPE_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPMGRD ,  Please Wait...
 Delete From &schema_user..TSMPMGRD WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPMTCT ,  Please Wait...
 Delete From &schema_user..TSMPMTCT WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPPA ,  Please Wait...
 Delete From &schema_user..TSMPPA WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPPRA ,  Please Wait...
 Delete From &schema_user..TSMPPRA WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPRA ,  Please Wait...
 Delete From &schema_user..TSMPRA WHERE TSMPERSN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMPROGM ,  Please Wait...
 Delete From &schema_user..TSMPROGM WHERE TSMPROGM_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSMPROGM ,  Please Wait...
--  Delete From &schema_user..TSMPROGM WHERE TSMPROGM_ORG_ID='ZZZZZZZZ' ;                              
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMPROJ ,  Please Wait...
 Delete From &schema_user..TSMPROJ WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPRPRA ,  Please Wait...
 Delete From &schema_user..TSMPRPRA WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPSA ,  Please Wait...
 Delete From &schema_user..TSMPSA WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPSRA ,  Please Wait...
 Delete From &schema_user..TSMPSRA WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPUMP ,  Please Wait...
 Delete From &schema_user..TSMPUMP WHERE TSMPUMP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMRFLBL ,  Please Wait...
 Delete From &schema_user..TSMRFLBL WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMSCTS ,  Please Wait...
 Delete From &schema_user..TSMSCTS WHERE TSMSOI_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMSPRNG ,  Please Wait...
 Delete From &schema_user..TSMSPRNG WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMSTATN ,  Please Wait...
 Delete From &schema_user..TSMSTATN WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMTBINF ,  Please Wait...
 Delete From &schema_user..TSMTBINF WHERE ALTERNATE_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
/*  commented out to keep the tsmuoa data.
-- Delete From &schema_user..TSMUOA WHERE TSMORGAN_IS_NUMBER=1 ;
PROMPT  Removing &YOUR_ORG's Rows from table TSMUOA ,  Please Wait...
 Delete From &schema_user..TSMUOA WHERE TSMORGAN_IS_NUMBER=
                     (select TSMORGAN_IS_NUMBER From &schema_user..TSmorgan where org_id='&YOUR_ORG') ;
*/
 COMMIT;
--commented out to keep the tsmuser data.
-- Delete From &schema_user..TSMUSER WHERE TSMORGAN_IS_NUMBER=1 ;
PROMPT  Removing &YOUR_ORG's Rows from table TSMUSER ,  Please Wait...
-- Delete From &schema_user..TSMUSER ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSMVSC ,  Please Wait...
 Delete From &schema_user..TSMVSC WHERE TSMVSC_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMWELL ,  Please Wait...
 Delete From &schema_user..TSMWELL WHERE TSMWELL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMWLE ,  Please Wait...
 Delete From &schema_user..TSMWLE WHERE TSMWELL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRAAL ,  Please Wait...
 Delete From &schema_user..TSRAAL WHERE TSMALP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRADL ,  Please Wait...
 Delete From &schema_user..TSRADL WHERE TSRADL_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSRANLPR ,  Please Wait...
 Delete From &schema_user..TSRANLPR WHERE TSRANLPR_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSRANLPR ,  Please Wait...
--  Delete From &schema_user..TSRANLPR WHERE TSRANLPR_ORG_ID='ZZZZZZZZ' ;
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSRBRG ,  Please Wait...
 Delete From &schema_user..TSRBRG WHERE TSRBRG_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRBRGI ,  Please Wait...
 Delete From &schema_user..TSRBRGI WHERE TSRBRGI_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRCCGA ,  Please Wait...
 Delete From &schema_user..TSRCCGA WHERE TSRCCGA_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRCHDEF ,  Please Wait...
 Delete From &schema_user..TSRCHDEF WHERE TSRCHDEF_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRCHGRP ,  Please Wait...
 Delete From &schema_user..TSRCHGRP WHERE TSRCHGRP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSRCITN ,  Please Wait...
 Delete From &schema_user..TSRCITN WHERE TSRCITN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSRCITN ,  Please Wait...
--  Delete From &schema_user..TSRCITN WHERE TSRCITN_ORG_ID='ZZZZZZZZ' ;
--  COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSRCLDES ,  Please Wait...
 Delete From &schema_user..TSRCLDES WHERE TSRRSULT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRCPA ,  Please Wait...
 Delete From &schema_user..TSRCPA WHERE TSMPROJ_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRDQL ,  Please Wait...
 Delete From &schema_user..TSRDQL WHERE TSRRSULT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSREOD ,  Please Wait...
 Delete From &schema_user..TSREOD WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFAFSA ,  Please Wait...
 Delete From &schema_user..TSRFAFSA WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFAPEA ,  Please Wait...
 Delete From &schema_user..TSRFAPEA WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFAPRA ,  Please Wait...
 Delete From &schema_user..TSRFAPRA WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFAQSA ,  Please Wait...
 Delete From &schema_user..TSRFAQSA WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFDACT ,  Please Wait...
 Delete From &schema_user..TSRFDACT WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFDSET ,  Please Wait...
 Delete From &schema_user..TSRFDSET WHERE TSRFDSET_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFLDPR ,  Please Wait...
 Delete From &schema_user..TSRFLDPR WHERE TSRFLDPR_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFQS ,  Please Wait...
 Delete From &schema_user..TSRFQS WHERE TSRFQS_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFQSDP ,  Please Wait...
 Delete From &schema_user..TSRFQSDP WHERE TSRFQSDP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFQSPA ,  Please Wait...
 Delete From &schema_user..TSRFQSPA WHERE TSRFQS_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRGRCFG ,  Please Wait...
 Delete From &schema_user..TSRGRCFG WHERE TSRGRCFG_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRHCSC ,  Please Wait...
 Delete From &schema_user..TSRHCSC WHERE TSRHCSC_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRLAB ,  Please Wait...
 Delete From &schema_user..TSRLAB WHERE TSRLAB_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSRLSPP ,  Please Wait...
 Delete From &schema_user..TSRLSPP WHERE TSRLSPP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
-- PROMPT  Removing ZZZZZZZZ's Rows from table TSRLSPP ,  Please Wait...
-- Delete From &schema_user..TSRLSPP WHERE TSRLSPP_ORG_ID='ZZZZZZZZ' ;
-- COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSROAPA ,  Please Wait...
 Delete From &schema_user..TSROAPA WHERE TSMORGAN_IS_NUMBER=
                     (select TSMORGAN_IS_NUMBER From &schema_user..TSmorgan where org_id='&YOUR_ORG') ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSROAPCA ,  Please Wait...
 Delete From &schema_user..TSROAPCA WHERE TSMORGAN_IS_NUMBER=
                     (select TSMORGAN_IS_NUMBER From &schema_user..TSmorgan where org_id='&YOUR_ORG') ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSROLSPA ,  Please Wait...
 Delete From &schema_user..TSROLSPA WHERE TSMORGAN_IS_NUMBER=
                     (select TSMORGAN_IS_NUMBER From &schema_user..TSmorgan where org_id='&YOUR_ORG') ;
 COMMIT;

PROMPT  Removing &YOUR_ORG's Rows from table TSROPPRD ,  Please Wait...
 Delete From &schema_user..TSROPPRD WHERE TSROPPRD_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRPOPA ,  Please Wait...
 Delete From &schema_user..TSRPOPA WHERE TSROPPRD_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRRCI ,  Please Wait...
 Delete From &schema_user..TSRRCI WHERE TSRRSULT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRRLRA ,  Please Wait...
 Delete From &schema_user..TSRRLRA WHERE TSRRSULT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRRQCAF ,  Please Wait...
 Delete From &schema_user..TSRRQCAF WHERE TSRRQCAF_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRRSULT ,  Please Wait...
 Delete From &schema_user..TSRRSULT WHERE TSRRSULT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRSDP ,  Please Wait...
 Delete From &schema_user..TSRSDP WHERE TSRSDP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRSMPLE ,  Please Wait...
 Delete From &schema_user..TSRSMPLE WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRSTVST ,  Please Wait...
 Delete From &schema_user..TSRSTVST WHERE TSRSTVST_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRTNOD ,  Please Wait...
 Delete From &schema_user..TSRTNOD WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRTOD ,  Please Wait...
 Delete From &schema_user..TSRTOD WHERE TSRFDACT_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRTPA ,  Please Wait...
 Delete From &schema_user..TSRTPA WHERE TSRTRIP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRTRIP ,  Please Wait...
 Delete From &schema_user..TSRTRIP WHERE TSRTRIP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRTSA ,  Please Wait...
 Delete From &schema_user..TSRTSA WHERE TSRTRIP_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

-- NEW STORET v2.0 Tables
-- NEW STORET v2.0 Tables
PROMPT  Removing &YOUR_ORG's Rows from table TSMBLOB ,  Please Wait...
 Delete From &schema_user..TSMBLOB WHERE TSMBLOB_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMFNA ,  Please Wait...
 Delete From &schema_user..TSMFNA WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMPSW ,  Please Wait...
 Delete From &schema_user..TSMPSW WHERE TSMSTATN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRFACOA ,  Please Wait...
 Delete From &schema_user..TSRFACOA WHERE TSMCPORG_ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSRDLIN ,  Please Wait...
 Delete From &schema_user..TSRDLIN WHERE TSRDLIN_ORG_ID='&YOUR_ORG'  ;
 COMMIT;

-- OLD Table no longer exists in STORET v2.0
--PROMPT  -- OLD Table no longer exists in STORET v2.0
--PROMPT  Removing &YOUR_ORG's Rows from table TSMAMDA ,  Please Wait...
-- Delete From &schema_user..TSMAMDA WHERE TSMMAD_ORG_ID='&YOUR_ORG'  ;
-- COMMIT;
-- OLD Table no longer exists in STORET v2.0
-- OLD Table no longer exists in STORET v2.0

PROMPT  Removing &YOUR_ORG's Rows from table TSMORGAN ,  Please Wait...
 Delete From &schema_user..TSMORGAN WHERE ORG_ID='&YOUR_ORG'  ;
 COMMIT;
PROMPT  Removing &YOUR_ORG's Rows from table TSMSOI ,  Please Wait...
 Delete From &schema_user..TSMSOI WHERE TSMSOI_ORG_ID='&YOUR_ORG'  ;
 COMMIT;


SPOOL OFF
-- SQL Plus Environment Variables
set echo off
set verify on
set feedback on
set termout on
set time off
set timing off
set heading on
set linesize 100
set pagesize 24
set serveroutput off

PROMPT DONE... Removing &YOUR_ORG's Rows from schema owner STORET1
set echo on
-- File: DEL_DEMO.SQL
-- @del_demo.sql  -- RE-RUN Script (if applicable)
exit
