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

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;

posted @   bule神  阅读(510)  评论(0编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示