MySQL操作程序十(选择零件,mscenq1.pl中的pat="parts_select",mscparts30.htm)
返回
[error] [client 127.0.0.1] DBD::mysql::db selectrow_array failed: Unknown column 'Y' in 'where clause' at ./pro/mscenq1.pl line 861
[error] [client 127.0.0.1] Use of uninitialized value in concatenation (.) or string at ./pro/mscenq1.pl line 865,
[error] [client 127.0.0.1] DBD::mysql::db do failed: Incorrect date value: '' for column 'time' at row 1 at ./pro/mscenq1.pl line 866,
[error] [client 127.0.0.1] Use of uninitialized value in concatenation (.) or string at ./pro/mscenq1.pl line 871,
861: (@{ $t{enq2list} } ) = $self->dbh->selectrow_array("SELECT * FROM enq2 WHERE id = $t{enq2oldid}");
865: $t{sql1} .= $t{time1} . '" where id = ' . $t{enq2_id};
866: $t{DO1} = $self->dbh->do($t{sql1});
871: $t{sql1} .= $t{makerid1} . '" where id = ' . $t{enq2_id};
问题分析:
mscenq1.pl
1:(@{ $t{enq2list} } ) = $self->dbh->selectrow_array("SELECT * FROM enq2 WHERE id = $t{enq2oldid}");
2:$t{enq2oldid} = $t{enq2oldids}[0];
3:push(@{ $t{enq2oldids} },$t{price1s}[6]);
4:@{ $t{price1s} } = split(/\//,$t{price1});
5:$t{price1} = $t{q}->param($t{NO_P1});
6:$t{price1} = $t{q}->param($t{NO_P1});
7:$t{NO_P1} = 'price1_' . $t{id};
mscshowparts20.pl
10:$t{NO_P1} = 'price1_' . $rec[0];
11:$t{sth} = $self->dbh->prepare("SELECT * FROM $t{ptable}");
12:$t{ptable} = sprintf("%06d",$t{tid});
$t{ptable} = 'a' . $t{ptable};
mscshowparts10.pl
20:$$row_ref{NO_P1} = 'price1_' . $rec[0]; # PRICE1
21:($row_ref,$self,$pref) = show_price1($row_ref,$self,$pref);
mscshowparts.pl
30:sub show_price1 {
my($row_ref,$self,$pref) = @_;
my(%t,@members,%price1);
mysql> show columns from a006128;
+--------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | text | YES | | NULL | |
| code | text | YES | | NULL | |
| dwg_id | int(11) | YES | | NULL | |
| Nuid | int(11) | YES | | NULL | |
| weight | int(11) | YES | | NULL | |
| price1 | text | YES | | NULL | |
| price2 | text | YES | | NULL | |
| memo | text | YES | | NULL | |
+--------+---------+------+-----+---------+----------------+
9 rows in set (0.16 sec)
mysql> select * from a000424\G
*************************** 1. row ***************************
id: 1
name: TRANSMITTER ASSY
code: KTBSSK04341
dwg_id: 1
Nuid: 1
weight: 1
price1: 720000=100=1=2008-06-02=8060205=98=95
price2: 792000.00=110=1=2008-06-03=1
memo: NULL
*************************** 2. row ***************************
id: 2
name: TRANSMITTER ASSY
code: KTBSSK04341
dwg_id: 1
Nuid: 1
weight: 1
price1: 0=100=1=0000-00-00=1
price2: 0=100=1=0000-00-00=1=1
memo: NULL
2 rows in set (0.00 sec)
继续分析问题:
1:price1的长度不对!(需要统一)
==>修改如下
增加: if ( $t{enq2oldid} ne 'Y' ) {
- ENQ数量修改时输入空格的对应,mscenq1.pl,pat=QTYchange
mscenq1.pl
for $n1 ( 0 .. $#{ $t{pppp3} } ) {
$t{pppp4} = $t{pppp3}[$n1];
$t{QQ1name} = $t{tttt2} . '=' . $t{pppp4};
$t{QQ1} = $t{q}->param($t{QQ1name});
if ( $t{QQ1} == 0 ) { # 这部分追加
$t{QQ1} = '0';
}
$t{QQQQ}{$t{QQ1name}} = $t{QQ1}; # enq2用
push(@{ $t{enq1_QTY2} },$t{QQ1});
}
输入空格
新
QTY: 18=12=12=12=1=6=6=6=6=36=36=3=6=48=12=12=2=24=3=1=6=3=12=2=6=2=6=6=6=0=1=1=3=0=1=3
旧
QTY: 18=12=12=12=1=6=6=6=6=36=36=3=6=48=12=12=2=24=3=1=6=3=12=2=6=2=6=6=6=12=1=1=3==1=3
-------------------------------------------------------------------------------
Argument "C" isn't numeric in numeric eq (==) at ./pro/mscenq1.pl line 1207,
for $n1 ( 0 .. $#{ $t{seriess} } ) {
$t{sid1} = $n1 + 1;
if ( $t{sid0} == $t{sid1} ) {
$series{line1} .= '';
} else {
$series{line1} .= '';
}
}
追加
if ( $t{sid0} eq 'C' ) {
$t{sid0} = 1;
}
--------------------------------------------------------------------------------
Use of uninitialized value in concatenation (.) or string at ./pro/mscenq1.pl line 1415
$t{line1} .= 'Engine NO=' . $t{id1} . ', Engine Type=' . $t{type1} . ', DWG=' . $t{DWG1};
$t{DWG1} = $t{DWGs}[$t{dwg1}];
は次のように変更する
if ($t{DWGs}[$t{dwg1}]) {
$t{DWG1} = $t{DWGs}[$t{dwg1}];
} else {
$t{DWG1} = 'NO';
}
mscenq1.pl的pat='parts_select'子程序
} elsif ( $t{pat} eq 'parts_select' ) {
# 取出数据
$t{tname} = $t{q}->param("tname");
$t{tid} = $t{q}->param("tid");
$t{plists} = $t{q}->param("plists");
$t{NE1} = $t{q}->param("NE1");
# 零件表名
$t{ptable} = sprintf("%06d",$t{tid});
$t{ptable} = 'a' . $t{ptable};
@{ $t{lists} } = split(/=/,$t{plists});
# 把数据写到enq1上去
# 先取出partsid和QTY
($t{ps},$t{Qs},$t{enq2s}) = $self->dbh->selectrow_array("SELECT partsid,QTY,enq2s FROM enq1 WHERE id = $t{enq1_id}");
@{ $t{enq2_ids} } = split(/=/,$t{enq2s});
$t{enq2_id} = $t{enq2_ids}[0];
@{ $t{pss} } = split(/==/,$t{ps});
@{ $t{Qss} } = split(/==/,$t{Qs});
$t{N1} = $t{NE1} - 1;
for $n ( 0 .. $#{ $t{pss} } ) {
if ( $n == $t{N1} ) {
$t{partsid} = $t{pss}[$n];
$t{QTY1s} = $t{Qss}[$n];
$t{NEn} = $n;
}
}
$t{QTY2s} = 0;
for $n ( 0 .. $#{ $t{lists} } ) {
$t{id} = $t{lists}[$n];
$t{NO} = 'qty_' . $t{id};
$t{NO_P1} = 'price1_' . $t{id};
$t{NO_P2} = 'price2_' . $t{id};
$t{qty1} = $t{q}->param($t{NO});
if ( $t{qty1} == 0 ) { # 如果忘记输入数量,就赋予10亿,然后再删除
$t{qty1} = 10000000000;
}
if ( $t{partsid} eq 'C' ) { # 处理没有零件的情况
$t{partsid} = $t{id};
$t{QTY1s} = $t{qty1};
$t{QTY2s} = $t{qty1};
} else {
$t{partsid} .= '=' . $t{id};
$t{QTY1s} .= '=' . $t{qty1};
if ( $t{QTY2s} ) {
$t{QTY2s} .= '=' . $t{qty1};
} else {
$t{QTY2s} = $t{qty1};
}
}
$t{price1} = $t{q}->param($t{NO_P1});
$t{price2} = $t{q}->param($t{NO_P2});
@{ $t{price1s} } = split(/\//,$t{price1});
push(@{ $t{enq2oldids} },$t{price1s}[6]);
}
$t{enq2oldid} = $t{enq2oldids}[0];
# 从旧enq2中取出time/makerid/discount0(以上为单个)
(@{ $t{enq2list} } ) = $self->dbh->selectrow_array("SELECT * FROM enq2 WHERE id = $t{enq2oldid}");
$t{time1} = $t{enq2list}[1];
# UPDATE enq2:time
$t{sql1} = 'UPDATE enq2 set time = "';
$t{sql1} .= $t{time1} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
$t{makerid1} = $t{enq2list}[7];
# UPDATE enq2:makerid
$t{sql1} = 'UPDATE enq2 set makerid = "';
$t{sql1} .= $t{makerid1} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
$t{discount0} = $t{enq2list}[15];
# UPDATE enq2:discount0
$t{sql1} = 'UPDATE enq2 set discount0 = "';
$t{sql1} .= $t{discount0} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
# UPDATA enq2:type1id, ==>$t{tid}
$t{sql1} = 'UPDATE enq2 set type1id = "';
$t{sql1} .= $t{tid} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
# UPDATA enq2:partsid => $t{plists}
$t{sql1} = 'UPDATE enq2 set partsid = "';
$t{sql1} .= $t{plists} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
# UPDATA enq2:QTY
$t{sql1} = 'UPDATE enq2 set QTY = "';
$t{sql1} .= $t{QTY2s} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
# 复数个enq2中取得价格和discount
$t{TEST} = 'enq2_id1==>' . $t{enq2oldids}[0];
for $n2 ( 0 .. $#{ $t{enq2oldids} } ) {
# 从旧enq2中取出type1id/partsid/price/discount,有复数个的可能性,其中discount有可能是'D'
$t{enq2oldid} = $t{enq2oldids}[$n2];
(@{ $t{enq2list} } ) = $self->dbh->selectrow_array("SELECT * FROM enq2 WHERE id = $t{enq2oldid}");
$t{enq2_tid} = $t{enq2list}[9];
$t{enq2_pid} = $t{enq2list}[10];
$t{enq2_price} = $t{enq2list}[13];
$t{enq2_discount} = $t{enq2list}[14];
@{ $t{enq2_tids} } = split(/==/,$t{enq2_tid});
@{ $t{enq2_pids} } = split(/==/,$t{enq2_pid});
@{ $t{enq2_prices} } = split(/=/,$t{enq2_price});
@{ $t{enq2_discounts} } = split(/=/,$t{enq2_discount});
$t{N1} = 0;
for $n ( 0 .. $#{ $t{enq2_tids} } ) {
$t{enq2_tid1} = $t{enq2_tids}[$n];
$t{enq2_pid1} = $t{enq2_pids}[$n];
if ( $t{enq2_tid1} == $t{tid} ) { # 相同TYPE
@{ $t{enq2_is} } = split(/=/,$t{enq2_pid1});
$t{N2} = 1 + $#{ $t{enq2_is} };
@{ $t{enq2_prs} } = splice(@{ $t{enq2_prices} },$t{N1},$t{N2});
if ( $t{enq2_discount} ne 'D' ) {
@{ $t{enq2_dis} } = splice(@{ $t{enq2_discounts} },$t{N1},$t{N2});
}
# 读入所有价格和DISCOUNT
for $n1 ( 0 .. $#{ $t{enq2_is} } ) {
$t{plist_price}{$t{enq2_is}[$n1]} = $t{enq2_prs}[$n1];
if ( $t{enq2_discount} ne 'D' ) {
$t{plist_dis}{$t{enq2_is}[$n1]} = $t{enq2_dis}[$n1];
}
}
} else {
@{ $t{enq2_is} } = split(/=/,$t{enq2_pids}[$n]);
$t{N1} = $t{N1} + $#{ $t{enq2_is} } + 1;
}
}
}
# UPDATA enq2:price
for $n ( 0 .. $#{ $t{lists} } ) {
$t{id} = $t{lists}[$n];
push(@{ $t{enq2_pricelist} },$t{plist_price}{$t{id}});
}
$t{enq2_pri1} = join('=',@{ $t{enq2_pricelist} });
$t{sql1} = 'UPDATE enq2 set price = "';
$t{sql1} .= $t{enq2_pri1} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
# UPDATA enq2:discount
if ( $t{enq2_discount} ne 'D' ) {
for $n ( 0 .. $#{ $t{lists} } ) {
$t{id} = $t{lists}[$n];
push(@{ $t{enq2_dislist} },$t{plist_dis}{$t{id}});
}
$t{enq2_dis1} = join('=',@{ $t{enq2_dislist} });
$t{sql1} = 'UPDATE enq2 set discount = "';
$t{sql1} .= $t{enq2_dis1} . '" where id = ' . $t{enq2_id};
$t{DO1} = $self->dbh->do($t{sql1});
}
# UPDATE quo2:暂时不做
# UPDATE enq1:partsid
$t{pss}[$t{NEn}] = $t{partsid}; # 零件编号的更新
$t{new1} = join("==",@{ $t{pss} });
$t{sql1} = 'UPDATE enq1 set partsid = "';
$t{sql1} .= $t{new1} . '" where id = ' . $t{enq1_id};
$t{DO1} = $self->dbh->do($t{sql1});
# UPDATE enq1:QTY
$t{Qss}[$t{NEn}] = $t{QTY1s}; # 零件数量的更新
$t{new1} = join("==",@{ $t{Qss} });
$t{sql2} = 'UPDATE enq1 set QTY = "';
$t{sql2} .= $t{new1} . '" where id = ' . $t{enq1_id};
$t{DO2} = $self->dbh->do($t{sql2});
}
返回