#!/usr/bin/env perl
#----------------------------------------------------------------------------
#
# Name: reset_dms_asn_members
# 
# This perl script is a testing tool that allows reruns of the
# insert_dms_associations.pl script to regenerate all records after
# a failure or for testing redeliveries. NOT TO BE DELIVERED.
#
# History:
# Date     OPR      Who         Reason
# -------- -------- ----------  ---------------------------------------------
# 08/18/05 54219    Baum        Initial code 
#----------------------------------------------------------------------------
# set up external routines
unshift @INC,(split /:/, $ENV{PATH});
require 'printmsg.pl';       # prints a formatted status message
require 'runsql.pl';         # run query returning only record count

    $DSQUERY=           $ENV{"DSQUERY"};
    $OPUS_DB=           lc($ENV{"OPUS_DB"});

#---------------------------------------------------------------------
# open database for queries
#---------------------------------------------------------------------
    $db = new ST_DBlib $DSQUERY, $OPUS_DB;
    die if $db == -1;

#---------------------------------------------------------------------
# delete all DMS asn_members
#---------------------------------------------------------------------
    $query = << "EOQ";
DELETE asn_members FROM asn_members q, dms_asn_id d
WHERE q.association_id = d.association_id 
EOQ

    $count = RunSql( $db, $query );
    PrintMsg("I","$count records deleted from asn_members");
     
#---------------------------------------------------------------------
# end of all queries
#---------------------------------------------------------------------
    $db->dbclose;
    exit(0);
