MySQL操作程序二十二(mscenq1.pl,删除主机和零件,d_parts)

返回

[error] [client 127.0.0.1] Use of uninitialized value in numeric eq (==) at ./pro/mscenq1.pl line 341 341: if ( $$pref{type_parts1}{$t{ttt2}}{$t{ppp3}[$n2]} == 1 ) { 改为===> 341: if ( $$pref{type_parts1}{$t{ttt2}}{$t{ppp3}[$n2]} ) { #---------删除一个Parts } elsif ( $t{pat} eq 'd_parts' ) { 341: if ( $$pref{type_parts1}{$t{ttt2}}{$t{ppp3}[$n2]} == 1 ) { 分析: 取出type1 @{ $t{type_partss} } = split(/=/,$$pref{type_parts}); $t{type1NO} = $t{type_partss}[0]-1; $t{type1id} = $self->dbh->selectrow_array("select type1id from enq1 where id = $t{enq1_id}"); @{ $t{type1ids} } = split(/==/,$t{type1id}); $t{type1id} = $t{type1ids}[$t{type1NO}]; $$pref{type_parts1}{$t{type1id}}{$t{type_partss}[1]} = 1; $$pref{type_parts}什么意图? if ( $t{NO} != $$pref{NO3} ) { push(@{ $t{list2ssnew} },$t{list2ss}[$n1]); } else { $$pref{type_parts} = $t{NO2} . '=' . $t{list2ss}[$n1]; }
使用者不按顺序输入时如何解决? [error] [client 127.0.0.1] Use of uninitialized value in numeric eq (==) at ./pro/mscenq1.pl line 725 [error] [client 127.0.0.1] Use of uninitialized value in numeric eq (==) at ./pro/mscenq1.pl line 340 340: if ( $$pref{type_parts1}{$t{ttt2}}{$t{ppp3}[$n2]} == 1 ) { 725:if ( $t{enq1_ids}{$b[$n]} == 0 ) {
# 删除指定的零件号码==>quo2 sub parts2 { my($pref) = @_; my(%t,$n,$n1); $t{list2} = $$pref{list2}; $t{NO} = $$pref{NO2}; $t{OK} = 0; @{ $t{list2s} } = split(/=/,$t{list2}); @{ $t{list2snew} } = (); for $n ( 0 .. $#{ $t{list2s} }) { $t{NO2} = $n + 1; if ( $t{NO} != $t{NO2} ) { push(@{ $t{list2snew} },$t{list2s}[$n]); $t{OK} = 1; } } if ( $t{OK} == 0 && $$pref{quo2_pat} eq 'percent' ) { $$pref{list2new} = 'P1'; } elsif ( $t{OK} == 0 && $$pref{quo2_pat} eq 'discount') { $$pref{list2new} = 'D'; } elsif ( $t{OK} == 0 && $$pref{quo2_pat} eq 'price') { $$pref{list2new} = 'P2'; } elsif ( $t{OK} == 0 && $$pref{quo2_pat} eq 'disc') { $$pref{list2new} = 'D0'; } elsif ( $t{OK} == 0 && $$pref{quo2_pat} eq 'price0') { $$pref{list2new} = 'P0'; } else { $$pref{list2new} = join('=',@{ $t{list2snew} }); } return($pref); } # 删除enq1的QTY sub parts21 { my($pref) = @_; my(%t,$n,$n1); $t{list2} = $$pref{list2}; $t{NO1} = $$pref{NO1}; $t{NO3} = $$pref{NO3}; @{ $t{list2s} } = split(/==/,$t{list2}); @{ $t{list2snew} } = (); @{ $t{list2ssnew} } = (); for $n ( 0 .. $#{ $t{list2s} }) { $t{NO2} = $n + 1; if ( $t{NO1} == $t{NO2} ) { @{ $t{list2ss} } = split(/=/,$t{list2s}[$n]); for $n1 ( 0 .. $#{ $t{list2ss} } ) { # 这儿注意!零件号码没有重复的,但是数量QTY当然有重复的! # next if ( $t{NO3} == $t{list2ss}[$n1] ); $t{NO} = $n1 + 1; if ( $t{NO} != $$pref{NO3} ) { push(@{ $t{list2ssnew} },$t{list2ss}[$n1]); } } $t{list2new} = join('=',@{ $t{list2ssnew} }); # 当所有零件都被删除时,必须留一个C if ( $t{list2new} !~ /=/ && $t{list2new} !~ /\d/ ) { $t{list2new} = 'C'; } push(@{ $t{list2snew} },$t{list2new}); } else { push(@{ $t{list2snew} },$t{list2s}[$n]); } } $$pref{list2new} = join('==',@{ $t{list2snew} }); return($pref); } #---------删除一个Parts } elsif ( $t{pat} eq 'd_parts' ) { $t{NO1} = $t{q}->param("NO1"); $t{NO3} = $t{q}->param("NO3"); # パーツ削除 $$pref{NO1} = $t{NO1}; $$pref{NO3} = $t{NO3}; $$pref{list2} = $self->dbh->selectrow_array("select partsid from enq1 where id = $t{enq1_id}"); ($pref) = parts20($pref); $t{sql} = 'UPDATE enq1 set partsid = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); # type1を取り出す @{ $t{type_partss} } = split(/=/,$$pref{type_parts}); $t{type1NO} = $t{type_partss}[0]-1; $t{type1id} = $self->dbh->selectrow_array("select type1id from enq1 where id = $t{enq1_id}"); @{ $t{type1ids} } = split(/==/,$t{type1id}); $t{type1id} = $t{type1ids}[$t{type1NO}]; $$pref{type_parts1}{$t{type1id}}{$t{type_partss}[1]} = 1; $t{enq2s} = $self->dbh->selectrow_array("select enq2s from enq1 where id = $t{enq1_id}"); @{ $t{enq2s_ids} } = split(/=/,$t{enq2s}); for $n ( 0 .. $#{ $t{enq2s_ids} } ) { $t{enq2_id} = $t{enq2s_ids}[$n]; ($t{type1id},$t{partsid},$t{QTY},$t{price},$t{discount}) = $self->dbh->selectrow_array("select type1id,partsid,QTY,price,discount from enq2 where id = $t{enq2_id}"); @{ $t{ttt1} } = split(/==/,$t{type1id}); @{ $t{ppp1} } = split(/==/,$t{partsid}); @{ $t{qqq1} } = split(/==/,$t{QTY}); @{ $t{prs} } = split(/=/,$t{price}); @{ $t{dis} } = split(/=/,$t{discount}); @{ $t{prs2} } = (); @{ $t{dis2} } = (); @{ $t{ppp6} } = (); @{ $t{qqq6} } = (); $t{NO} = 0; for $n1 ( 0 .. $#{ $t{ttt1} } ) { $t{ttt2} = $t{ttt1}[$n1]; $t{ppp2} = $t{ppp1}[$n1]; $t{qqq2} = $t{qqq1}[$n1]; @{ $t{ppp3} } = split(/=/,$t{ppp2}); @{ $t{qqq3} } = split(/=/,$t{qqq2}); @{ $t{ppp4} } = (); @{ $t{qqq4} } = (); for $n2 ( 0 .. $#{ $t{ppp3} } ) { $t{NO}++; if ( $$pref{type_parts1}{$t{ttt2}}{$t{ppp3}[$n2]} == 1 ) { } else { push(@{ $t{ppp4} },$t{ppp3}[$n2]); push(@{ $t{qqq4} },$t{qqq3}[$n2]); push(@{ $t{prs2} },$t{prs}[$t{NO}-1]); push(@{ $t{dis2} },$t{dis}[$t{NO}-1]); } } $t{ppp5} = join('=',@{ $t{ppp4} }); $t{qqq5} = join('=',@{ $t{qqq4} }); push(@{ $t{ppp6} },$t{ppp5}); push(@{ $t{qqq6} },$t{qqq5}); } $t{ppp7} = join('==',@{ $t{ppp6} }); $t{qqq7} = join('==',@{ $t{qqq6} }); $t{prs3} = join('=',@{ $t{prs2} }); $t{dis3} = join('=',@{ $t{dis2} }); $t{sql} = 'UPDATE enq2 set partsid = "'; $t{sql} .= $t{ppp7} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); $t{sql} = 'UPDATE enq2 set QTY = "'; $t{sql} .= $t{qqq7} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); $t{sql} = 'UPDATE enq2 set price = "'; $t{sql} .= $t{prs3} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); if ( $t{discount} ne 'D' ) { $t{sql} = 'UPDATE enq2 set discount = "'; $t{sql} .= $t{dis3} . '" where id = '; $t{sql} .= $t{enq2_id}; $t{DO} = $self->dbh->do($t{sql}); } } # パーツのQTY削除 $$pref{list2} = $self->dbh->selectrow_array("select QTY from enq1 where id = $t{enq1_id}"); ($pref) = parts2($pref); $t{sql} = 'UPDATE enq1 set QTY = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); # quo2のprice/percent/price0の削除 $$pref{list2} = $self->dbh->selectrow_array("select price from quo2 where id = $t{enq1_id} && price != 'P2'"); if ( $$pref{list2} ) { ($pref) = parts2($pref); $t{sql} = 'UPDATE quo2 set price = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); } $$pref{list2} = $self->dbh->selectrow_array("select price0 from quo2 where id = $t{enq1_id} && price0 != 'P0'"); if ( $$pref{list2} ) { ($pref) = parts2($pref); $t{sql} = 'UPDATE quo2 set price0 = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); } $$pref{list2} = $self->dbh->selectrow_array("select percent from quo2 where id = $t{enq1_id} && percent != 'P1'"); if ( $$pref{list2} ) { ($pref) = parts2($pref); $t{sql} = 'UPDATE quo2 set percent = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); } $$pref{list2} = $self->dbh->selectrow_array("select discount from quo2 where id = $t{enq1_id} && discount != 'D'"); if ( $$pref{list2} ) { ($pref) = parts2($pref); $t{sql} = 'UPDATE quo2 set discount = "'; $t{sql} .= $$pref{list2new} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); }
先删除零件的话,该程序没有问题。 #---------删除一台主机 } elsif ( $t{pat} eq 'd_engine' ) { $$pref{NO1} = $t{q}->param("NO1"); $t{item} = $t{q}->param("item"); @{ $t{items} } = split(/,/,$t{item}); for $n ( 0 .. $#{ $t{items} } ) { $t{item1} = $t{items}[$n]; $$pref{old1} = $self->dbh->selectrow_array("select $t{item1} from enq1 where id = $t{enq1_id}"); $$pref{item1} = $t{item1}; ($pref) = d_engine($pref); $t{sql} = 'UPDATE enq1 set ' . $t{item1} . ' = "'; $t{sql} .= $$pref{new1} . '" where id = '; $t{sql} .= $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); } # 删除主机 sub d_engine { my($pref) = @_; my(%t,$n); if ( $$pref{old1} =~ /==/ ) { @{ $t{old_list} } = split(/==/,$$pref{old1}); @{ $t{new_list} } = (); for $n ( 0 .. $#{ $t{old_list} } ) { $t{NO1} = $n + 1; next if ( $t{NO1} == $$pref{NO1} ); push(@{ $t{new_list} },$t{old_list}[$n]); } $$pref{new1} = join('==',@{ $t{new_list} }); # 只有一个的情况下,置换成'B' } else { if ( $$pref{item1} eq 'type1id' ) { $$pref{new1} = 'B'; # type1id的情况 } else { $$pref{new1} = 'C'; # parts1id,QTY的情况 } } return($pref); }
返回