Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> What's wrong with this code!!!

What's wrong with this code!!!

From: Corncrowe <corncrowe_at_aol.com>
Date: 1997/10/20
Message-ID: <19971020232800.TAA22814@ladder02.news.aol.com>#1/1

Hello, I wanted to know if anyone saw something wrong with the following code.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
create or replace procedure sp_temp_aging as ordnum number (10) := 0;
ordvol number;
v_from_date date;
v_to_date date;

cursor c_orders is select ord_id from temp_aging order by ord_id;

BEGIN
v_to_date := TO_DATE(TO_CHAR(SYSDATE,'YYYYMMDD')||' 05:00','YYYYMMDD HH24:MI');
v_from_date := v_to_date - 1;

dbms_output.put_line('From Date: '||TO_CHAR(v_from_date,'mm/dd/yy hh24:mi'));
dbms_output.put_line('To Date: '||TO_CHAR(v_to_date,'mm/dd/yy hh24:mi'));

delete from temp_aging where ord_id is not null; commit;

insert into temp_aging (name,lifted_term_id,diff,vol,ord_id) select /*+RULE*/ t.name,
o.lifted_term_id,to_date(ov.creation_date,'dd-mon-yy') -
decode(o.lifted_end_time,null,to_date(o.lifted_start_time,'dd-mon-yy'), to_date(o.lifted_end_time,'dd-mon-yy')) diff, 0 vol,o.ord_id
from order_versions ov, orders o,terminals t, order_status_versions osv where ov.ver_nbr = osv.ov_ver_nbr

and osv.ov_ord_ord_id = ov.ord_ord_id
and osv.os_stat_cd = 6
and ov.ord_ord_id = o.ord_id
and t.term_id = o.lifted_term_id

and ov.creation_date between v_from_date AND v_to_date;

commit;
open c_orders;
loop

	fetch c_orders into ordnum;
	exit when c_orders%notfound;
	select /*+RULE*/ sum(pov.lifted_gross_vol) into ordvol
	  from product_order_versions pov, order_status_versions osv
	  where pov.ov_ord_ord_id = ordnum
	  and pov.ov_ord_ord_id = osv.ov_ord_ord_id
	  and pov.ov_ver_nbr = osv.ov_ver_nbr
	  and osv.os_stat_cd = 6;
	update temp_aging set vol = ordvol
	  where ord_id = ordnum;	

end loop;
commit;
close c_orders;
END;
/
SHOW ERRORS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thanks,

Jon Received on Mon Oct 20 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US