您好我想使用多个值来同时执行脚本 我有两个变量,其中一个变量将有多个值。 我可以在begin语句中为VAR_INVC_ID使用多个值,以便脚本对两个具有sgmt_i = 2的invc_id执行操作吗?
DECLARE
VAR_INVC_ID INT;
VAR_SGMT_ID INT;
BEGIN
VAR_INVC_ID := 19762884; 19764495;
VAR_SGMT_ID := 2;
INSERT INTO IORDL
SELECT 0,
DC_ID,
WHSE_ID,
ORD_ID,
SGMT_ID,
ORDD_ID,
CUST_ID,
PROD_ID,
INVC_ID,
'A',
ORD_QTY,
0,
SHIP_QTY,
NULL,
'D',
'MK',
'FLOW',
ORDER_TYPE_ID,
'011',
NULL,
'N',
NULL,
'exceedMK',
SYSDATE,
NULL,
NULL,
NULL,
UNIT_SHIP_CSE,
PRDD_ID,
NULL,
OSTA_ID,
ORD_RQST_DEL_DT,
ORD_RQST_DEL_TIM,
DEFER_BILL_DT,
PCDE_ID,
COMMODITY_TYPE,
SUB_TYPE,
ORDER_DT,
ORDER_TIM,
RTL_COST,
AVG_CSE_WGT,
CSE_UNIT,
FT_ID,
FTD_ID,
SELD_ID
FROM IORDL
WHERE (ORD_ID, SGMT_ID, ORDD_ID) NOT IN
(SELECT ORD_ID, SGMT_ID, ORDD_ID
FROM IORDL
WHERE INVC_ID = VAR_INVC_ID
AND SGMT_ID = VAR_SGMT_ID
AND ERCD_ID = 'MK')
AND ERCD_ID = 'SP'
AND INVC_ID = VAR_INVC_ID
AND SGMT_ID = VAR_SGMT_ID;
-- Backup ishd records;
INSERT INTO ISHD_BKP
SELECT *
FROM ISHD
WHERE INVC_ID = VAR_INVC_ID AND SGMT_ID = VAR_SGMT_ID;
-- UPDATE ishs spmd_units for corresponding ishd records
MERGE INTO ISHS SH
USING ( SELECT CURR_PAL_NO, SUM (PROD_QTY / UNIT_SHIP_CSE) QTY
FROM ISHD
WHERE INVC_ID = VAR_INVC_ID AND SGMT_ID = VAR_SGMT_ID
GROUP BY CURR_PAL_NO) SD
ON (SH.CURR_PAL_NO = SD.CURR_PAL_NO)
WHEN MATCHED
THEN
UPDATE SET
SH.SPMD_UNITS = SH.SPMD_UNITS - SD.QTY, CHANGE_USER = 'exceedMK';
-- DELETE ishd records;
DELETE ISHD
WHERE INVC_ID = VAR_INVC_ID AND SGMT_ID = VAR_SGMT_ID;
-- UPDATE IORD
UPDATE IORD SET OSTA_ID='CLO' WHERE INVC_ID = VAR_INVC_ID AND SGMT_ID = VAR_SGMT_ID;
COMMIT;
END;
答案 0 :(得分:0)
您的inv_id变量应声明为整数数组
In [1]: a = [(5, 3), (1, 4), (1, 7), (12, 7), (8, 3), (12, 4), (12, 5)]
In [2]: dict(sorted(a, key=lambda x: (x[0], x[1])))
Out[2]: {1: 7, 5: 3, 8: 3, 12: 7}