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

返回

enq1_parts2(輸入數(shù)據(jù)出錯) 界面輸出時,輸出出錯的數(shù)據(jù),以便查找! 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] ) { # ==>增加判據(jù) $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 # 程序檢查數(shù)據(jù)庫數(shù)據(jù) use strict; use DBI; my(%t,$n,@fld,@rec,$pref); # 連接數(shù)據(jù)庫 $$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"; # 關(guān)閉數(shù)據(jù)庫 $$pref{dbh}->disconnect; exit; ----------------------------------------------------------------------------- # 把雙引號置換成單引號 $t{partsname} =~ s/\"/\'/g; $t{partscode} =~ s/\"/\'/g;
返回
夹江县| 沙河市| 浦东新区| 监利县| 巴彦淖尔市| 民丰县| 璧山县| 大同县| 屏边| 临安市| 恩施市| 自治县| 井研县| 封丘县| 高青县| 开化县| 台东市| 天津市| 新津县| 清丰县| 衢州市| 南靖县| 迁安市| 江陵县| 通道| 三明市| 塘沽区| 明溪县| 永德县| 茶陵县| 辽阳县| 郴州市| 简阳市| 锡林浩特市| 辉南县| 安溪县| 宜兴市| 长治县| 定兴县| 大名县| 浮山县|