PROCEDURE test IS comp_return_rec_ m_purchase_comp_return_tab%Rowtype; barcode_hist_rec_ m_barcode_inv_tran_hist_Tab%ROWTYPE; -- CURSOR get_comp_return IS SELECT * FROM m_purchase_comp_return_tab m; -- CURSOR get_barcode_hist IS SELECT m.* FROM m_barcode_inv_tran_hist_Tab m , m_barcode_status_tab n WHERE n.barcode_no = m.barcode_no AND n.co_order_no = comp_return_rec_.bill_no AND n.co_line_no = comp_return_rec_.item_seq_no AND n.source = '採購訂單'; BEGIN OPEN get_comp_return; LOOP FETCH get_comp_return INTO comp_return_rec_ ; EXIT WHEN get_comp_return%NOTFOUND; barcode_hist_rec_.barcode_no := null; OPEN get_barcode_hist; FETCH get_barcode_hist INTO barcode_hist_rec_; CLOSE get_barcode_hist; IF barcode_hist_rec_.barcode_no IS NOT NULL THEN UPDATE m_purchase_comp_return_tab m SET m.barcode_created_flag = 2 WHERE m.bill_no = comp_return_rec_.bill_no AND m.item_seq_no = comp_return_rec_.item_seq_no ; END IF ; END LOOP; CLOSE get_comp_return; END test;
loop 的話空值時不會賦值的sql