我有以下 PL/SQL 代码,用于调用 API(由客户端提供)以调整帐户。
如果在编写此块时有任何缺点或更好的方法或方法,我想改进我的代码。
PS 不幸的是,我们的客户仍在为他们的产品使用 Oracle 8i。
PLSQL 代码
DECLARE
v_account_id account_adjustments.account_id%TYPE;
v_adj_no account_adjustments.adj_no%TYPE;
v_old_qty product_warehouse.new_qty%TYPE;
v_new_qty product_warehouse.new_qty%TYPE;
BEGIN
v_old_qty := NULL;
v_new_qty := NULL;
FOR acnt IN (SELECT *
FROM temp_table a) LOOP
SELECT a.new_qty
INTO v_old_qty
FROM product_warehouse a
WHERE ( a.product_no = acnt.product_no );
Adjust_accounts (in_service_product_no => acnt.product_no,
in_service_qty => acnt.qty,
out_account_id => v_account_id,
out_adj_no => v_adj_no);
SELECT b.new_qty
INTO v_new_qty
FROM product_warehouse b
WHERE ( b.product_no = acnt.product_no );
INSERT INTO account_year_todate
(product_no,
account_id,
adj_no,
qty_bad,
qty_warehouse,
qty_factory)
VALUES ( acnt.product_no,
v_account_id,
v_adj_no,
acnt.qty,
v_old_qty,
v_new_qty );
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.Put_line ('exceptions '
|| SQLERRM);
ROLLBACK;
END;