CREATE OR REPLACE PROCEDURE P_ORDERS_MAIL
IS
v_no1 number;
v_no2 number;
v_code varchar2(20);
v_program varchar2(20);
v_subject varchar2(1000);
v_content varchar2(30000);
v_cust_shortname varchar2(200);
BEGIN
cursor order_1 is
select so_code,count(so_seq) from bu_so_items
where to_date(to_char(sysdate,'yyyymmdd'),'yyyymmdd') - to_date(to_char(created_date,'yyyymmdd'),'yyyymmdd')<=2
group by so_code;
open order_1;
loop
fetch order_1 into v_code,v_no1;
select count(so_seq) into v_no2 from bu_so_items_tmp
where serial_no=(select serial_no
from bu_saleords_tmp
where so_code=v_code);
if v_no1>v_no2 then
v_program:='p_orders_mail'
select cust_shortname
into v_cust_shortname
from BU_CUSTOMERS
where cust_id = vcust_id;
v_subject := '通知 -'||to_char(sysdate,'yyyy/mm/dd')||'('||v_cust_shortname||')';
end if;
end loop;
close order_1;
END ;
错误 提示如下图。
IS
v_no1 number;
v_no2 number;
v_code varchar2(20);
v_program varchar2(20);
v_subject varchar2(1000);
v_content varchar2(30000);
v_cust_shortname varchar2(200);
BEGIN
cursor order_1 is
select so_code,count(so_seq) from bu_so_items
where to_date(to_char(sysdate,'yyyymmdd'),'yyyymmdd') - to_date(to_char(created_date,'yyyymmdd'),'yyyymmdd')<=2
group by so_code;
open order_1;
loop
fetch order_1 into v_code,v_no1;
select count(so_seq) into v_no2 from bu_so_items_tmp
where serial_no=(select serial_no
from bu_saleords_tmp
where so_code=v_code);
if v_no1>v_no2 then
v_program:='p_orders_mail'
select cust_shortname
into v_cust_shortname
from BU_CUSTOMERS
where cust_id = vcust_id;
v_subject := '通知 -'||to_char(sysdate,'yyyy/mm/dd')||'('||v_cust_shortname||')';
end if;
end loop;
close order_1;
END ;
错误 提示如下图。
--少逗号吧
v_program:='p_orders_mail'
---你的多处有错误 就不细说了
---试试下面改正的
CREATE OR REPLACE PROCEDURE P_ORDERS_MAIL
IS
v_no1 number;
v_no2 number;
v_code varchar2(20);
v_program varchar2(20);
v_subject varchar2(1000);
v_content varchar2(3000);
v_cust_shortname varchar2(200);
cursor order_1 is select so_code,count(so_seq) from bu_so_items
where trunc(sysdate)-trunc(created_date)<=2 group by so_code;
BEGIN
open order_1;
loop
fetch order_1 into v_code,v_no1;
exit when order_1%notfound;
select count(so_seq) into v_no2 from bu_so_items_tmp
where serial_no in (select serial_no from bu_saleords_tmp where so_code=v_code);
if v_no1>v_no2 then
v_program:='p_orders_mail';
select cust_shortname into v_cust_shortname from BU_CUSTOMERS where cust_id = vcust_id;
v_subject := '通知 -'||to_char(sysdate,'yyyy/mm/dd')||'('||v_cust_shortname||')';
end if;
end loop;
close order_1;
END ;