常用的sql语句(存储过程语法)

1.存储过程语法


①package 

create or replace package PKG_RPT_WAREHOUSE is

-- Author :
-- Created : 2018/9/28 17:17:39
-- Purpose : 仓库统计报表

--生成每日库存统计
PROCEDURE GEN_WAREHOUSE_STORAGE;

end PKG_RPT_WAREHOUSE;

 ②package body 

create or replace package body PKG_RPT_WAREHOUSE is

--生成库存每日报表

PROCEDURE GEN_WAREHOUSE_STORAGE AS
BEGIN(

CREATE OR REPLACE PROCEDURE INVENTORY_FREEZING(v_own_uuid in varchar2) as
begin(带参数)


--0.删除当日无效数据
delete from RPT_WAREHOUSE_STORAGE t
where trunc(t.storage_date) = trunc(sysdate);


--1 insert into语句
insert into rpt_warehouse_storage_detail
(storage_date, area_code, pallet_code, pallet_type, warehouse_name)
select trunc(sysdate),
a.area_code,
t.pallet_code,
decode(instr(t.pallet_code, 'ES'), 1, 'SMALL', 'BIG'),
a.tj_area_name
from wm_inventory_detail_area t
left join wm_pallet w
on w.pallet_uuid = t.pallet_uuid
left join wm_warehouse_area a
on a.wwa_uuid = t.wwa_uuid
left join wm_in_label i
on i.ilb_uuid = t.ilb_uuid
and i.is_active = 'Y'
and i.inventory_qty > 0
where exists (select 1
from wm_in_label ww
where ww.ilb_uuid = t.ilb_uuid
and ww.is_active = 'Y'
and ww.inventory_qty > 0)
and t.is_active = 'Y'
and a.is_active = 'Y'
and a.tj_area_name = '康捷空仓库'
group by t.pallet_code, a.area_code, a.tj_area_name;
 
--2.修改语句
merge into (select *
from RPT_WAREHOUSE_STORAGE t
where t.warehouse_name = '康捷空仓库'
and t.storage_date = trunc(sysdate)) a
using (select sum(small_in) small_in,
sum(big_in) big_in,
'康捷空仓库' warehouse_name
from (select decode(t.pallet_type, 'SMALL', t.inventory_qty, 0) small_in,
decode(t.pallet_type, 'BIG', t.inventory_qty, 0) big_in
from RPT_EI_WAREHOUSE_DTL t
where trunc(t.count_date) = trunc(sysdate)
and not exists
(select 1
from RPT_EI_WAREHOUSE_DTL oi
where oi.il_unique_box_code = t.il_unique_box_code
and trunc(t.count_date - 1) =
trunc(oi.count_date))
when matched then
update set a.BIG_IN = b.BIG_IN, a.SMALL_IN = b.SMALL_IN;

END GEN_WAREHOUSE_STORAGE;

end PKG_RPT_WAREHOUSE;

 

转载于:https://www.cnblogs.com/cxks-xu/p/10448952.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值