3,499
社区成员
发帖
与我相关
我的任务
分享
前阵子写的
create or replace procedure sp_get_busi(vv out varchar2,p_OutCursor out sys_refcursor)
is
tb_name varchar2(100);
v_sql varchar2(1000);
has_updateTM number;
max_tm varchar(100);
start_tm varchar(100);
begin
tb_name:='srcs.CM_BUSI_'|| to_char(sysdate,'yyyymm') ||'@link_mcm';--当前的月份表
select count(*) into has_updateTM from scm_updatewuzi_tm where update_type=0 ;--是否存在更新时间 0是物资 1是号码
if has_updateTM =0 then
start_tm:=to_char(add_months(sysdate,-1),'yyyy-mm-dd hh24:mi:ss');
v_sql:='select so_nbr, busi_code,so_org_id,so_date from '||
tb_name || ' where so_date > to_date('''||start_tm||''',''yyyy-mm-dd hh24:mi:ss'') and so_date <=to_date(to_char(sysdate,''yyyy-mm-dd hh24:mi:ss''),''yyyy-mm-dd hh24:mi:ss'') order by so_date';--
else
select to_char(max(tm),'yyyy-mm-dd hh24:mi:ss') into max_tm from scm_updatewuzi_tm where update_type=0 ;
v_sql:='select so_nbr, busi_code,so_org_id,so_date from '||
tb_name || ' where so_date >to_date('''||max_tm||''',''yyyy-mm-dd hh24:mi:ss'') and so_date <=to_date(to_char(sysdate,''yyyy-mm-dd hh24:mi:ss''),''yyyy-mm-dd hh24:mi:ss'') order by so_date';--
end if;
vv:=v_sql;
open p_OutCursor for v_sql;
exception
when others then
rollback;
end sp_get_busi;
create or replace p_test
(
i_eno varchar2,
i_ename varchar2,
i_sal number,
ocursor out sys_refcursor
)
as
begin
open ocursor for
select * from tabname
where (eno = str_eno or i_eno is null)
and (ename = str_ename or i_ename is null)
and (sal = int_sal or i_sal is null);
end p_test;