#!/usr/bin/perl -w
=item
command to update all the sites:

for i in `ls /etc/opals/conf/`; do cp -p /www/opals/script/getRecFormList /tmp/urt; perl -pi -e "s/_MY_SITE_/$i/" /tmp/urt; sudo /tmp/urt; done

=cut
use lib '/www/opals/module';
use Opals::Context("/etc/opals/conf/_MY_SITE_");

use strict;
use DBI;
#use Getopt::Std;

use POSIX qw(
    ceil
);

my $dbh = Opals::Context->dbh();
END {
    if ($dbh) {
        $dbh->disconnect();
    }
}

$| = 1;
# Cotes start...
my $sth = $dbh->prepare(<<_SQL_);
select   rid ,barcode 
from    opl_item 
where barcode regexp ?
_SQL_

my $sthXml = $dbh->prepare(<<_SQL_);
select UNCOMPRESS(marcXml) recXml from opl_recordArchive 
where rid=? 
_SQL_

      my  $delXML = '';
        open REC_DEL, "</tmp/file1.txt";
        my $bc;
        while (<REC_DEL>) {
            chomp;
            $bc =  $_;
            $bc =~ s/$\n+//;
            $bc =~ s/\r//;
            #print "[".$bc."]";
            $sth->execute($bc);
            while (my ($rid,$barcode) = $sth->fetchrow_array) {
                print "$rid\n";
                 $sthXml->execute($rid);
                 while (my ($recXml) = $sthXml->fetchrow_array) {
                    print "$rid\n";
                    $delXML .= "\n" . $recXml if($recXml ne "");
                 }
            }

        }
        $sth->finish;

        close REC_DEL;

  open debug,">/tmp/delXml.txt";
      print debug "$delXML";
      close debug;


=item

my $sth = $dbh->prepare(<<_SQL_);
select   rid ,barcode 
from    opl_item 
where barcode regexp ?
_SQL_

    my $dir;
    foreach my $bc (qw( )){
        $sth->execute($bc);
       #  print "1:::$bc\n";

        while (my ($rid,$barcode) = $sth->fetchrow_array) {
            print "$rid\n";
        }
    }
    $sth->finish;

=cut


# Codes end.

exit 0;

#////////////////////////////////////////////////////////////////////////////
