procedure
changespecialdiscount
(compid_in
invarchar2
,ccid_in
invarchar2
,cono_in
invarchar2)is
sum_cc_all
number(14
,4):=
0;wsp_disc
number(14
,4);wspcl_disc
number
;cnt_u
number
;cnt_i
number(4
);cnt2
number(4
) :=1;
tot_disc
number(14
,4) :=0;
act_cd
varchar2(2
);witem_no
varchar2(4
);wcost_cc
number(14
,4);wqty_order
number(14
,4);wlp_contr
number(14
,4);wstatus
varchar2(4
);wsrce_type
varchar2(1
);wsp_per_unit_contr
number(14
,4);cursor
c1 is
select
item_no,cost_cc_contr,qty_order,lp_cust_contr,status,srce_type,sp_per_unit_contr
from
tbco_item
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in ;
begin
select
sum( sp_per_unit_contr
*qty_order )
into
sum_cc_all
from
tbco_item
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in ;
select
disc_amt
into
wspcl_disc
from
tbco_head
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in ;
select
count(*
) into
cnt_u
from
tbco_item
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in
anddate_cancel
isnull
andnvl( sp_per_unit_contr, 0)
<>0;
select
count(*
) into
cnt_i
from
tbco_item
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in ;
open
c1;for
idx in1
..cnt_i loop
fetch
c1 into
witem_no, wcost_cc, wqty_order,
wlp_contr, wstatus, wsrce_type, wsp_per_unit_contr;
select
activity_code
into
act_cd
from
tbcm_status
where
system_code ='
co'andtable_level ='
2'anddata_type
=wsrce_type
and(status_name1
=wstatus
orstatus_name2
=wstatus );
--< special discount distribution >
ifwsp_per_unit_contr =0
oract_cd ='
15'then
wsp_disc :=0
;elsif cnt2
<
cnt_u
then
wsp_disc :
=round
(wspcl_disc
*( wsp_per_unit_contr
*wqty_order
/sum_cc_all),2);
cnt2 :
=cnt2 +1
;elsif cnt2
>=
cnt_u
then
wsp_disc :
=wspcl_disc
-tot_disc;
endif
;
--accumulation of distributed selling price
tot_disc :
=tot_disc
+round
(wsp_disc,2);
--updating item special discount
update
tbco_item
setspecial_disc
=round
(wsp_disc,2),
date_modify
=sysdate
where
comp_id
=compid_in
andcc_id
=ccid_in
andco_no
=cono_in
anditem_no
=witem_no;
endloop;
close
c1;
end;
BroadcastReciever簡單用法示例
生命週期非常短,在接受到廣播時建立,onrecieve 方法執行完後銷毀 10s內onrecieve 方法未執行完,會出現anr錯誤 broadcastreciever簡單用法示例 傳送廣播 intent intent new intent this,sendbraodcast intent 注 1...
oracle cursor 學習小結
一 概念 游標 用來查詢資料庫,獲取記錄集合 結果集 的指標,可以讓開發者一次訪問一行結果集,在每條結果集上作操作。二 分類 1 靜態游標 分為顯式游標和隱式游標。2 ref 游標 是一種引用型別,類似於指標。三 詳細內容 1 顯式游標 cursor 游標名 引數 返回值型別 is select 語...
oracle cursor 學習小結
游標 用來查詢資料庫,獲取記錄集合 結果集 的指標,可以讓開發者一次訪問一行結果集,在每條結果集上作操作。二 分類 1 靜態游標 分為顯式游標和隱式游標。2 ref游標 是一種引用型別,類似於指標。三 詳細內容 1 顯式游標 cursor游標名 引數 返回值型別 is select語句 生命週期 a...