小崔说SAP技术博客 - 游标
type: channel
link: https://sapxiaocui.top/index.php/tag/%E6%B8%B8%E6%A0%87/
items: SAP HANA数据库 存储过程使用游标循环更新数据库

SAP HANA数据库 存储过程使用游标循环更新数据库
type: item
date: 2025-05-24T06:09:00+00:00
description: 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;