可以將下面提到的代碼製作得更緊湊,我試圖將同一機架的電纜長度定爲長度固定爲6mts的同一機架insatallation,然後從一個機架到另一個機架由.5mtrs每個遞增,其餘是 具有下述列如何計算相對於兩列條目的長度
ID RACK_A RACK_B LENGTH
1 RK 1 RK 1
2 RK 2 RK 1
3 RK 1 RK 2
4 MCR DESK PCR
5 CAR INGEST
6 PCR CAR
等等約2000條目
UPDATE MASTER_SCHEDULE
SET CABLE_LENTH =
switch(
RACK_A='RK 1' AND RACK_B='RK 1', 6
, RACK_A='RK 2' AND RACK_B='RK 2', 6
, RACK_A='RK 3' AND RACK_B='RK 3', 6
, RACK_A='RK 4' AND RACK_B='RK 4', 6
, RACK_A='RK 5' AND RACK_B='RK 5', 6
, RACK_A='RK 6' AND RACK_B='RK 6', 6
, RACK_A='RK 7' AND RACK_B='RK 7', 6
and so on say more 20 statements all with LENGTH = 6
, RACK_A='RK 1' AND RACK_B='RK 2' OR RACK_A = 'RK 2' AND RACK_B = 'RK 1',6.5
, RACK_A='RK 1' AND RACK_B='RK 3' OR RACK_A = 'RK 3' AND RACK_B = 'RK 1',7
, RACK_A='RK 1' AND RACK_B='RK 4' OR RACK_A = 'RK 4' AND RACK_B = 'RK 1',7.5
, RACK_A='RK 1' AND RACK_B='RK 5' OR RACK_A = 'RK 5' AND RACK_B = 'RK 1',8
, RACK_A='RK 1' AND RACK_B='RK 6' OR RACK_A = 'RK 6' AND RACK_B = 'RK 1',8.5
, RACK_A='RK 1' AND RACK_B='RK 7' OR RACK_A = 'RK 7' AND RACK_B = 'RK 1',9
and so on each LENGTH incremented by +.5
, RACK_A= 'MCR DESK' AND RACK_B='PCR=' OR RACK_A= 'PCR' AND RACK_B='MCR_DESK',54
, RACK_A= 'CAR' AND RACK_B='INGEST' OR RACK_A= 'INGEST' AND RACK_B='CAR',47
and so on each length is random figure ,
, true, 0)
WHERE ID>=1 AND ID<= 2000
它給了標準表達式中的數據類型不匹配代碼3030 SQLSTATE 22005 –
確保我的假設是正確的:「*列RACK_A和RACK_B中的所有數據格式爲」RK {房間號}「*」。否則,查詢將不起作用,我們需要找到另一種方法從RACK_A和RACK_B中獲取房間號。 – har07
「CABLE_LENTH」列的數據類型是什麼? – har07