我正在try 将数据插入到一个forall
循环中.在这种情况下,我不能使用临时变量并预先设置函数的结果.
该函数只是将一个数字映射到一个字符串:
create or replace function GetInvoiceStatus(status number)
return nvarchar2
as
begin
case status
when 0 then return 'New';
when 200 then return 'Sent';
when 300 then return 'Accepted';
end case;
return '';
end;
当我像这样调用此函数时:
select GetInvoiceStatus(200) from dual;
我得到了适当的结果.
然而,当我try 插入数据时,我得到了错误.
这forall
个插页:
forall i in 1.. INVOICE_DATA.COUNT
insert into "InvoiceAudit"
("PropertyName", "OldValue", "NewValue" (
VALUES ('Status', (GetInvoiceStatus(invoice_data(i).status)),
((GetInvoiceStatus((select "Status" from "Invoice" where "InvoiceId" = invoice_data(i).invoiceId)))));
但是,我得到以下错误:
[65000][6592]ORA-06592: 执行CASE语句时未找到CASE[2023-06-01 15:02:57] ORA-06512:"PUBLIC.GETINVOICESTATUS",第9行[2023-06-01 15:02:57] ORA-06512:"PUBLIC.INVOICESSP"第63行[2023-06-01 15:02:57] 职位:5
我已经仔细判断过了,并且INVOICE_DATA(I)的结果.Status和其他SELECT值都是有效参数(并且包含了它们的用例),并且在存储过程外调用时返回适当的字符串.
语法有什么地方错了吗?
如果可能的话,我想继续使用forall
,因为它比常规的for
循环快得多.