我有这个功能:
Procedure UpdateDefaultWeight ( vYear Number, costWeight Number, qualityWeight Number, serviceWeight Number )
AS
type weight_table is table of Number(5,2) index by varchar2(50);
weightArray weight_table;
currentPosition varchar2(50);
Begin
weightArray('Cost Weighting') := costWeight;
weightArray('Quality Weighting') := qualityWeight;
weightArray('Service Weighting') := serviceWeight;
currentPosition := weightArray.first;
Loop
Exit When currentPosition is null;
Insert Into GVS.GVSSD16_DFLT_WEIGHT
( cal_year, metric_name, metric_val )
Values
( vYear, currentPosition, weightArray(currentPosition) );
currentPosition := weightArray.next(currentPosition);
End Loop;
END;
现在当我写它时,它只是做一个 INSERT。但是,我需要它来 UPSERT。我查看了有关 MERGE 的文档,但主要是让我对如何将语法应用于我的特定案例感到困惑。
有人愿意帮助 Oracle 新手吗?