欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2024-01-10 22:08:14
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 ......
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;