heting

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  40 随笔 :: 9 文章 :: 45 评论 :: 0 Trackbacks

2010年10月11日 #

 

create or replace package CARD_SERVICE_DAY_VIEW_PARAM  is 
   
function set_param(num varcharreturn varchar
   
function get_param  return varchar

   
end CARD_SERVICE_DAY_VIEW_PARAM; 
commit;
   
   
create or replace package body CARD_SERVICE_DAY_VIEW_PARAM is 
       paramValue 
varchar(10); 
       
function set_param(num varcharreturn varchar is 
       
begin 
         paramValue:
=num; 
         
return num; 
        
end;  
       
       
function get_param return varchar is 
       
begin 
         
return paramValue; 
       
end
       
   
end CARD_SERVICE_DAY_VIEW_PARAM;    
commit;

create or replace view CARD_SERVICE_DAY_VIEW as 
select
cs.id,
cs.card_id,
cs.lock_money,
to_char(cs.check_time,
'yyyy-MM-dd hh24:mi'as check_time,
cs.name,cs.phone,( months_between(to_date(CARD_SERVICE_DAY_VIEW_PARAM.get_param(),
'yyyyMMdd'),
to_date(to_char(cs.CHECK_TIME,
'yyyyMMdd'),'yyyyMMdd'))  ) as curr_batch,
(
select count(1from transaction where card_id=cs.card_id and tran_time between cs.check_time and to_date(CARD_SERVICE_DAY_VIEW_PARAM.get_param(),'yyyyMMdd'and (curr_bal-money)<cs.lock_money) as condition,
(
select count(1from service_transaction where batch=(months_between(to_date(CARD_SERVICE_DAY_VIEW_PARAM.get_param(),'yyyyMMdd'),to_date(to_char(cs.CHECK_TIME,'yyyyMMdd'),'yyyyMMdd'))) and s_id=cs.id) as hasAudit 
from card_service cs 
where cs.state='T' 
and 
months_between(to_date(CARD_SERVICE_DAY_VIEW_PARAM.get_param(),
'yyyyMMdd'),to_date(to_char(cs.CHECK_TIME,'yyyyMMdd'),'yyyyMMdd')) in (1,2,3,4,5,6
order by cs.card_id
commit;
posted @ 2010-10-11 15:26 贺挺 阅读(519) | 评论 (0)编辑 收藏