通过发票编号取凭证编号,返回多行值,拼接到一起

function get_doc_sequence_value(p_invoice_num varchar2) return varchar2 is v_doc_sequence_value varchar2(2000); cursor cur_doc (l_invoice varchar2 )is select doc_sequence_value from ap_invoices_all where invoice_num = l_invoice and cancelled_date is null; l_count number:=0; begin begin select count(*) into l_count from ap_invoices_all where invoice_num = p_invoice_num and cancelled_date is null; exception when others then v_doc_sequence_value := ”; end; for l_cur_doc in cur_doc(p_invoice_num) loop if l_count = 1 then v_doc_sequence_value:=l_cur_doc.doc_sequence_value; else if v_doc_sequence_value is null then v_doc_sequence_value:=l_cur_doc.doc_sequence_value; else v_doc_sequence_value:=v_doc_sequence_value||’,’||l_cur_doc.doc_sequence_value; end if ; end if ; end loop ; return v_doc_sequence_value; end;

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐