我收到了错误消息 " MERGE语句尝试多次更新或删除同一行。"
当我们运行我们的代码时。我很惊讶我们会收到该错误消息,因为代码没有进行合并。这是代码:
$qry = 'SELECT "PrintSamples"."PrintSampleID", "PrintSamples"."TestPatternName", "PrintSamples"."PrintCopyID",
"DigitalImages"."CaptureTime", "PrintSampleAnalyses"."psaTicket", "Measurements"."MeasurementID", "Measurements"."MeasurementUuid",
SUBSTRING("OperatorLastName",1,1) AS "lastInitial", SUBSTRING("OperatorFirstName",1,1) AS "firstInitial",
"ParameterValues"."ParameterID", "ParameterName", "TargetName", "ParameterValues"."ParameterValue"
FROM "ParameterValues"
LEFT JOIN "Measurements" ON "ParameterValues"."MeasurementID"="Measurements"."MeasurementID"
LEFT JOIN "PrintSampleAnalyses" ON "PrintSampleAnalyses"."psaID"="Measurements"."psaID"
LEFT JOIN "DigitalImages" ON "DigitalImages"."ImageID"="PrintSampleAnalyses"."ImageID"
LEFT JOIN "PrintSamples" ON "DigitalImages"."PrintSampleID"="PrintSamples"."PrintSampleID"
LEFT JOIN "Sessions" ON "Sessions"."SessionID"="PrintSampleAnalyses"."SessionID"
LEFT JOIN "Operators" ON "Operators"."OperatorID"="Sessions"."OperatorID"
LEFT JOIN "ParameterNames" ON "ParameterNames"."ParameterID"="ParameterValues"."ParameterID"
LEFT JOIN "Targets" ON "Targets"."TargetID"="Measurements"."TargetID"
WHERE (';
// this list comes from the "MeasurementNames" table
foreach ($measurementIDs as $mid){
if($mid[0] == "AvgGhostValAsSir77") $qry .= '(("ParameterName" LIKE ' . "'%AvgGhostValAsSir77%'" . ') AND ("TargetName"=' . "'" . $mid[1] . "')) OR ";
else if($mid[0] == "MaxNegGhostingValAsSir77") $qry .= '(("ParameterName" LIKE ' . "'%MaxNegGhostingValAsSir77%'" . ') AND ("TargetName"=' . "'" . $mid[1] . "')) OR ";
else $qry .= '(("ParameterName"=' . "'" . $mid[0] . "'" . ') AND ("TargetName"=' . "'" . $mid[1] . "')) OR ";
}
$qry = substr ($qry, 0, -4);
$qry .= ") ";
$qry .= ' AND ("ParameterValues"."ParameterValue" != -99999) ORDER BY "PrintSampleID", "MeasurementID"';
dataLog("Start pq query");
$result = pg_query ($pg_conn, $qry);
当我查看代码时,我没有看到任何重复,但它不应该首先出现错误消息,因为它不是合并。
以下是错误消息的开头:
" SELECT" PrintSamples"。" PrintSampleID", " PrintSamples"。" TestPatternName"," PrintSamples"。" PrintCopyID", " DigitalImages"。" CaptureTime"," PrintSampleAnalyses"。" psaTicket", "测量"。" MeasurementID","测量"。" MeasurementUuid", SUBSTRING(" OperatorLastName" 1,1)AS" lastInitial", SUBSTRING(" OperatorFirstName" 1,1)AS" firstInitial", " ParameterValues"。" ParameterID"," ParameterName"," TargetName", "的parameterValues""的parameterValue" FROM" ParameterValues" LEFT JOIN "测量"上 "的parameterValues"" MeasurementID" ="测量"" MeasurementID"剩下 加入" PrintSampleAnalyses"上 " PrintSampleAnalyses"" psaID" ="测量"" psaID" LEFT JOIN " DigitalImages"上 " DigitalImages""图像标识" =" PrintSampleAnalyses""图像标识" LEFT JOIN " PrintSamples"上 " DigitalImages"" PrintSampleID" =" PrintSamples"" PrintSampleID"剩下 加入"会议"上 "会话"" SessionID的" =" PrintSampleAnalyses"" SessionID的" LEFT JOIN "算子" ON"运营商"。"运营商ID" ="会话"。"运营商ID"剩下 JOIN" ParameterNames"上 " ParameterNames""参数标识" ="的parameterValues""参数标识"剩下 加入"目标" ON"目标"。" TargetID" ="测量"。" TargetID"哪里 ((" ParameterName" =' MeanLs')AND(" TargetName" =' Background.BL'))或 ((" ParameterName" =' MeanLs')AND(" TargetName" =' S3.005'))或......&#34 ;
以下是我们在错误消息结束时看到的内容的一部分: " ...
(" TargetName" =' Rogum'))或 ((" ParameterName" =' 1.0_AveOfAve_DensityAs938')AND (" TargetName" =' Rogum'))OR((" ParameterName" LIKE '%AvgGhostValAsSir77%')和(" TargetName" =' HalfToneArea'))或 ((" ParameterName" =' GhostingAmplitude')AND (" TargetName" =' HalfToneArea'))OR((" ParameterName" LIKE '%MaxNegGhostingValAsSir77%')AND(" TargetName" =' HalfToneArea'))或 ((" ParameterName" =' MaxPosGhostingValAsSir77')AND (" TargetName" =' HalfToneArea'))或((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; pos#1'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; pos#5'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; pos#9'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; pos#1'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; pos#5'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; pos#9'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; neg#1'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; neg#5'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9h.1; neg#9'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; neg#1'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; neg#5'))OR((" ParameterName" =' widthA')AND (" TargetName" =' S9v.1; neg#9'))OR((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.Y020'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.Y040'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.Y100'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.M020'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.M040'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.M100'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.C020'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.C040'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.C100'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.K020'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.K040'))或((" ParameterName" =' NMF')AND (" TargetName" =' FF.80x80.K100'))或((" ParameterName" =' VisualNoiseHF') AND(" TargetName" =' FF.16x16.Y020'))或 ((" ParameterName" =' VisualNoiseHF')AND(" TargetName" =' FF.16x16.Y040')) 或((" ParameterName" =' VisualNoiseHF')和 (" TargetName" =' FF.16x16.M020'))或((" ParameterName" =' VisualNoiseHF') AND(" TargetName" =' FF.16x16.M040'))或 ((" ParameterName" =' VisualNoiseHF')AND(" TargetName" =' FF.16x16.C020')) 或((" ParameterName" =' VisualNoiseHF')和 (" TargetName" =' FF.16x16.C040'))或((" ParameterName" =' VisualNoiseHF') AND(" TargetName" =' FF.16x16.K020'))或 ((" ParameterName" =' VisualNoiseHF')AND(" TargetName" =' FF.16x16.K040')) 或((" ParameterName" =' VBSHorizontal')AND (" TargetName" =' FF.196x214.Y050'))或((" ParameterName" =' VBSVertical') AND(" TargetName" =' FF.196x214.Y050'))或 ((" ParameterName" =' VBSHorizontal')AND (" TargetName" =' FF.196x214.M050'))或((" ParameterName" =' VBSVertical') AND(" TargetName" =' FF.196x214.M050'))或 ((" ParameterName" =' VBSHorizontal')AND (" TargetName" =' FF.196x214.C050'))或((" ParameterName" =' VBSVertical') AND(" TargetName" =' FF.196x214.C050'))或 ((" ParameterName" =' VBSHorizontal')AND (" TargetName" =' FF.196x214.K050'))或((" ParameterName" =' VBSVertical') AND(" TargetName" =' FF.196x214.K050'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.Y020'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.Y040'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.Y100'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.M020'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.M040'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.M100'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.C020'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.C040'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.C100'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.K020'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.K040'))或 ((" ParameterName" =' Mottle_as_SIR71_G-Level')AND (" TargetName" =' FF.80x80.K100'))或((" ParameterName" =' HDST')AND (" TargetName" =' T40Sv.010'))或((" ParameterName" =' HDST2')AND (" TargetName" =' T40Sv.010'))或((" ParameterName" =' HDST')AND (" TargetName" =' T40Sh.010'))或((" ParameterName" =' HDST2')AND (" TargetName" =' T40Sh.010'))或((" ParameterName" =' HDST')AND (" TargetName" =' T40Sv.030'))或((" ParameterName" =' HDST2')AND (" TargetName" =' T40Sv.030'))或((" ParameterName" =' HDST')AND (" TargetName" =' T40Sh.030'))或((" ParameterName" =' HDST2')AND (" TargetName" =' T40Sh.030')))AND(" ParameterValues"。" ParameterValue" != -99999)ORDER BY" PrintSampleID"," MeasurementID"
我能想到的是,我们的GhostingAmplitude被解释为与使用" like"的语句相同。从我所读过的关于类似陈述的内容来看,它不应该这样做。它仍然无法解释为什么会出现一个关于合并的错误消息。
我最近已经阅读了以下内容:
http://stackoverflow.com/questions/1434028/problem-with-sql-merge-statement