我的sql需要帮助有问题。 我的原始代码:
DECLARE
TYPE RecordTyp IS RECORD (v_vendor_name vendorinvoices.vendor_name%TYPE,
v_invoice_total vendorinvoices.invoice_total%TYPE,
v_invoice_due_date vendorinvoices.invoice_due_date%TYPE
);
rec1 RecordTyp;
BEGIN
select vendor_name,invoice_total,to_char(invoice_due_date,'fmMONTH DD YYYY') into rec1
from VendorInvoices
where Percentage(invoice_total,total_invoice_amount) > 70 order by vendor_name ;
END;
/
我收到错误"确切的提取返回超过请求的行数"。 因此,我通过以下方式修复了它:
DECLARE
TYPE RecordTyp IS RECORD (v_vendor_name vendorinvoices.vendor_name%TYPE,
v_invoice_total vendorinvoices.invoice_total%TYPE,
v_invoice_due_date vendorinvoices.invoice_due_date%TYPE
);
rec1 RecordTyp;
BEGIN
for rec in (
select vendor_name,invoice_total,to_char(invoice_due_date,'fmMONTH DD YYYY') into rec1
from VendorInvoices
where Percentage(invoice_total,total_invoice_amount) > 70 order by vendor_name )
loop
DBMS_OUTPUT.PUT_LINE(RPAD(rec1.v_VENDOR_NAME,35) || RPAD(rec1.v_invoice_total,35) || RPAD(rec1.v_invoice_due_date,35) );
end loop;
END;
/
但是,我不知道如何显示选择语句的结果,或者我不知道我是否修正了。 我只收到一条消息,"完成匿名阻止"甚至认为我的DBMS输出已打开。
请帮助我如何显示结果或告诉我是否正确/错误! P / S:我可以使用CURSOR,但要求要求将select语句放在BEGIN ... END
之间谢谢,