SAP HANA数据库 存储过程使用游标循环更新数据库
DECLARE CURSOR c_products FOR SELECT distinct T1."U_BPLId",T1."U_BILL_1",T0."U_FinishedItemCode",T0."U_ActDelDate" FROM "@TEST" T0 INNER JOIN "@TEST" T1 ON T0."DocEntry" = T1."DocEntry" WHERE T0."DocEntry" = list_of_cols_val_tab_del; DECLARE BPLId NVARCHAR(10); DECLARE CashBill NVARCHAR(50); DECLARE FinishedItemCode NVARCHAR(50); DECLARE ActDelDate NVARCHAR(50); FOR cur_row AS c_products DO BPLId := cur_row."U_BPLId"; CashBill := cur_row."U_BILL_1"; FinishedItemCode := cur_row."U_FinishedItemCode"; ActDelDate := cur_row."U_ActDelDate"; -- 处理每条记录 UPDATE "INV1" T0 FROM "INV1" T0 INNER JOIN "OINV" T1 ON T0."DocEntry" =T1."DocEntry" SET T0."U_FinancialAudit" = 'Y' ,T0."U_Auditor" = 'manager' ,T0."U_FinancialDate" = NOW() WHERE T0."U_CashBill" = :CashBill AND T0."ItemCode" = :FinishedItemCode AND (TO_CHAR( T0."ActDelDate", 'YYYY/MM' ) = :ActDelDate OR TO_CHAR( T0."ActDelDate", 'YYYY/MM' ) IS NULL) AND T1."BPLId" = :BPLId; END FOR;