Chinaunix首页 | 论坛 | 博客
  • 博客访问: 487911
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-13 13:18:15

1.    tracer.pl   "queuename"
usage: tracer.pl "XF_TOPOSGRD"
Description: Trace the records from inbound queue to outbound queue base on the queue name and key value.
Implementation:
a.  define transaction table to contain a transaction id, trasaction name, related inbound, outbound, map id.
b. tracer.pl use queuename check against the inbound's queuename, and get related transaction information.
c. get the map id's primay key information as  select criteria and prompt input for the key field
eg.
#>tracer.pl "XF_TOPOSGRD"
please input -
xf_datetime:
2008-02-25 15:14:53
xf_grstorecode:

xf_grno:
110004_056
xf_sku:
A09w38403201001

return:
a. Send out at successfully
b. Fail:


#!/usr/bin/perl
require '/opt/ws1/run_control.pl';
my $queuename=$ARGV[0];
my $stagedbh=DBI->connect("DBI:mysql:database=$localdatabase;host=$localdbhost","$localdbuser","$localdbpass",{'RaiseError'=>1, 'AutoCommit' => 0}) or die "cannot connect!\n";
$stagedbh->do("SET NAMES 'utf8'");
$idth=$stagedbh->prepare(qq/select transaction_id  from transaction_tbl where src_tbl="$queuename"/);
$idth->execute();
while($tr_id=$idth->fetchrow_array){
$id=$tr_id;
}
$trth=$stagedbh->prepare(qq/select *  from transaction_tbl where transaction_id="$id"/);
$trth->execute();
while(@trrow=$trth->fetchrow_array){
##src_table
push @table, $trrow[5];
push @map,$trrow[9];
push @pos,$trrow[8];
}
my $stage=$table[0];
my $inbound=$table[1];
my $outbound=$table[2];
my $map_id=$map[0];
my $pos_table=$pos[2];
if($outbound=~/,/){
@outbound=split /,/, $outbound;
}

#print "stage:$stage\n;
#print "inbound:$inbound\n";
#print "outbound:$outbound\n";
#print "map_id:$map_id\n";
#print "pos_table:$pow_table\n";
$src_table=lc($stage);
#print "src_table:$src_table\n";
$sth=$stagedbh->prepare(qq/select * from database_field_map where src_tables_name="$src_table" and map_id=$map_id/);
$sth->execute();
print "\n";
print " #############Please Input:###############\n";
while (@row=$sth->fetchrow_array){
push @key,$row[6];
push @src_fields,$row[4];
#print "pri_key:$row[6]\n";
#$key=1 this field is pri_key.
if ($row[6]==1){
print "$row[4]:\n";
chomp($key_value=);
print "\n";
$where.="$row[4]=\"$key_value\"";
$and=" and ";
$where=$where.$and;
      }
  }
#print "where:$where\n";
substr($where,-5)=~s/$and//g;
$statement="select STATUS_FLAG from $queuename where $where";
#print "stage_select:$statement\n";
foreach(@outbound){
@region=substr($_,-2,2);
}
$stagedbh->do("use wdms");
$wdth=$stagedbh->prepare(qq/$statement/);
$wdth->execute();
while ($status_flag=$wdth->fetchrow_array){
if($status_flag==1)
{
print " Success to $inbound!\n\n";
}
else {
print " Fail to $inbound!\n\n";
  }
}

$stagedbh->do("use ws1");

$statement2="select status_flag from $inbound where $where";
#print "inbound_select:$statement2\n";
$inth=$stagedbh->prepare(qq/$statement2/);
$inth->execute();
while (@row=$inth->fetchrow_array){
$status_flag=$row[0];
#print "status_flag:$status_flag\n";
 foreach(@outbound){
  $field_count=$stagedbh->selectrow_array(qq/select count(*) from $_ where $where/);
#print "count:$field_count\n";
  if($field_count>=1 && $status_flag==1){
    print " Success to $_!\n\n";
   }#if
     
 else {
 print " Fail to $_!\n\n";
  }#else
  }#foreach
}#while


foreach(@outbound){
$statement3="select status_flag from $_ where $where";
#print $statement3."\n";
#print "outbound_select:$statement3\n";
$outh=$stagedbh->prepare(qq/$statement3/);
$outh->execute();
while (@status_flag=$outh->fetchrow_array){
#print "status:$status_flag\n";
if($status_flag[0]==1)
{
print " Success to POS's $pos_table!\n\n";
}
else {
print " Fail to POS's $pos_table!\n\n";
  }
}
}

 
阅读(277) | 评论(0) | 转发(0) |
0

上一篇:ws2 email

下一篇:showqueuename.pl

给主人留下些什么吧!~~