我在创建此程序时遇到问题,它将用于打印某个发票号的帐单模型。这就是我到目前为止所做的,我目前只是想在为账单做视觉资料之前让它运行起来。事情是,我无法弄清楚是什么让它不能正常运行。我也得到了“找不到预期的FROM关键字”错误。
set serveroutput on;
create or replace procedure facture_client (numfacture invoices.ino%type) IS
detail_ino detail.ino%type;
detail_qty detail.qty%type;
detail_price detail.price%type;
invoices_idate invoices.idate%type;
invoices_itotal invoices.itotal%type;
invoices_salesman invoices.salesman%type;
customer_cno customer.cno%type;
customer_address customer.address%type;
customer_city customer.city%type;
customer_state customer.state%type;
customer_zip customer.zip%type;
customer_phone customer.phone%type;
salesman_nom salesman.nom%type;
begin
select detail.ino into detail_ino, detail.qty into detail_qty, detail.price into detail_price,
invoices.idate into invoices_idate, invoices.itotal into invoices_itotal, invoices.salesman into invoices_salesman,
customer.cno into customer_cno, customer.company into customer_company, customer.address into customer_address, customer.city into customer_city,
customer.state into customer_state, customer.zip into customer_zip, customer.phone into customer_phone,
salesman.nom into salesman_nom
from detail
join invoices on detail.ino = invoices.ino
join customer on invoices.cno = customer.cno
join salesman on invoices.salesman = salesman.salesman
where detail.ino = numfacture;
end;
答案 0 :(得分:4)
因为您只有一个INTO
语句的多个 SELECT
关键字。
在SELECT
列表中写下所有列之后,将其缩小为一个,如下所示:
select detail.ino, detail.qty, detail.price
invoices.idate, invoices.itotal,
invoices.salesman, customer.cno,
customer.company , customer.address,
customer.city, customer.state,
customer.zip, customer.phone, salesman.nom
into detail_ino, detail_qty, detail_price,
invoices_idate, invoices_itotal,
invoices_salesman, customer_cno,
customer_company, customer_address,
customer_city, customer_state,
customer_zip, customer_phone,salesman_nom
from detail
join invoices
on detail.ino = invoices.ino
join customer
on invoices.cno = customer.cno
join salesman
on invoices.salesman = salesman.salesman
where detail.ino = numfacture;
甚至更好地与别名表一起使用,如下所示:
select d.ino, d.qty, d.price
i.idate, i.itotal,
i.salesman, c.cno,
c.company , c.address,
c.city, c.state,
c.zip, c.phone, s.nom
into detail_ino, detail_qty, detail_price,
invoices_idate, invoices_itotal,
invoices_salesman, customer_cno,
customer_company, customer_address,
customer_city, customer_state,
customer_zip, customer_phone,salesman_nom
from detail d
join invoices i
on d.ino = i.ino
join customer c
on i.cno = c.cno
join salesman s
on i.salesman = s.salesman
where d.ino = numfacture;