MySQL操作程序二十七(enq1_parts1,mscenq1_parts1.pl,mscenq1_parts2.pl)

返回

enq1_parts2(输入数据出错) 界面输出时,输出出错的数据,以便查找! mscenq1_parts2.pl %seen = (); $t{name_code_length} = -1; for $n ( 0 .. $#{ $t{codes} } ) { if ( $t{names}[$n] && $t{codes}[$n] ) { $t{name_code} = $t{names}[$n] . '-' . $t{codes}[$n]; unless ( $seen{$t{name_code}} ) { $t{name_code_length}++; $seen{$t{name_code}} = 1; } } } ==>修改如下,增加$t{partscode1}输出! $t{name_code_length} = -1; $t{partscode1} = ''; for $n ( 0 .. $#{ $t{codes} } ) { if ( $t{names}[$n] && $t{codes}[$n] ) { $t{name_code} = $t{names}[$n] . '-' . $t{codes}[$n]; if ( $seen{$t{name_code}} ) { $t{partscode1} = $t{partscode1} . $t{name_code} . ' '; $t{partscode1} = $t{partscode1} . $t{name_code} . ' '; } else { $t{name_code_length}++; $seen{$t{name_code}} = 1; } } }
$t{template} = $self->load_tmpl('mscenq1_parts22.htm') || die "error loading tmpl"; [error] [client 127.0.0.1] Use of uninitialized value in concatenation (.) or string at ./pro/mscenq1.pl line 686 [error] [client 127.0.0.1] Use of uninitialized value in numeric eq (==) at ./pro/mscenq1.pl line 726 686:$t{line1} = $t{n1} . '____' . $t{c1} . '____' . $t{DWG0_id}; 726:if ( $t{enq1_ids}{$b[$n]} == 0 ) { 空白的零件也能输入? [error] [client 127.0.0.1] Use of uninitialized value in concatenation (.) or string at ./pro/mscenq1_parts2.pl line 53 53: $t{name_code} = $t{names}[$n] . '-' . $t{codes}[$n]; 零件输入长度出错时, 修改如下: if ( $t{names}[$n] && $t{codes}[$n] ) { # ==>增加判据 $t{name_code} = $t{names}[$n] . '-' . $t{codes}[$n]; unless ( $seen{$t{name_code}} ) { $t{name_code_length}++; $seen{$t{name_code}} = 1; } }

enq1.pl, input_parts部分增加删除程序(写入的程序在mscenq1_parts2.pl) # 中间删除 $t{p0} = ''; $t{sql} = 'UPDATE enq1 SET tmp_pname = "'; $t{sql} .= $t{p0} . '" WHERE id = ' . $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); $t{sql} = 'UPDATE enq1 SET tmp_pcode = "'; $t{sql} .= $t{p0} . '" WHERE id = ' . $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); $t{sql} = 'UPDATE enq1 SET tmp_pqty = "'; $t{sql} .= $t{p0} . '" WHERE id = ' . $t{enq1_id}; $t{DO} = $self->dbh->do($t{sql}); ---------------------------------------------------------------------- mysql> show columns from enq1; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | time | date | YES | | NULL | | | ourref | char(11) | YES | | NULL | | | owner | int(11) | YES | | NULL | | | ownerno | varchar(100) | YES | | NULL | | | hullnoid | int(11) | YES | | NULL | | | type1id | text | YES | | NULL | | | partsid | text | YES | | NULL | | | QTY | text | YES | | NULL | | | memo | text | YES | | NULL | | | LANGUAGEid | int(11) | YES | | NULL | | | makerid | int(11) | YES | | NULL | | | enq2s | text | YES | | NULL | | | seriesid | text | YES | | NULL | | | tmp_pname | text | YES | | NULL | | | tmp_pcode | text | YES | | NULL | | | tmp_pqty | text | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ 17 rows in set (0.00 sec) mysql> ALTER TABLE enq1 ADD tmp_pname TEXT; Query OK, 12383 rows affected (1.63 sec) Records: 12383 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE enq1 ADD tmp_pcode TEXT; Query OK, 12383 rows affected (0.52 sec) Records: 12383 Duplicates: 0 Warnings: 0 mysql> ALTER TABLE enq1 ADD tmp_pqty TEXT; Query OK, 12383 rows affected (0.48 sec) Records: 12383 Duplicates: 0 Warnings: 0 mysql> show columns from enq1; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | time | date | YES | | NULL | | | ourref | char(11) | YES | | NULL | | | owner | int(11) | YES | | NULL | | | ownerno | varchar(100) | YES | | NULL | | | hullnoid | int(11) | YES | | NULL | | | type1id | text | YES | | NULL | | | partsid | text | YES | | NULL | | | QTY | text | YES | | NULL | | | memo | text | YES | | NULL | | | LANGUAGEid | int(11) | YES | | NULL | | | makerid | int(11) | YES | | NULL | | | enq2s | text | YES | | NULL | | | seriesid | text | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ 14 rows in set (0.13 sec)
[Sun Sep 12 11:41:05 2010] [error] [client 127.0.0.1] Use of uninitialized value in string ne at ./pro/mscenq1.pl line 1144, <CONFIG> line 11., referer: 1143: ($t{price},$t{price0}) = $self->dbh->selectrow_array("SELECT price,price0 FROM quo2 WHERE id = $$pref{id} and price != 'P2'"); 1144: if ( $t{price} ne 'P2' ) { ---------------------------------- price是null的时候的处理方法? 写一个程序检查所有quo2的price项目 把1144改为 if ( $t{price} && $t{price} ne 'P2' ) { # show_ietm1.pl # 程序检查数据库数据 use strict; use DBI; my(%t,$n,@fld,@rec,$pref); # 连接数据库 $$pref{dsn} = "DBI:mysql:host=localhost;database=cookbook"; $$pref{dbh} = DBI->connect($$pref{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n"; $$pref{dbh}->do("SET NAMES utf8"); if(!$$pref{dbh}){ print "SQL read ERROR!\n"; exit; } # 取出price $t{sth} = $$pref{dbh}->prepare("select * from quo2"); $t{sth}->execute; while (@rec = $t{sth}->fetchrow_array) { print "$rec[0]==>$rec[11]\n"; } $t{sth}->finish; #print "ptable=$t{ptable}\n"; # 关闭数据库 $$pref{dbh}->disconnect; exit; ----------------------------------------------------------------------------- # 把双引号置换成单引号 $t{partsname} =~ s/\"/\'/g; $t{partscode} =~ s/\"/\'/g;
返回