ssm调用oracle存储过程

本文介绍了一个Oracle存储过程的创建方法,该过程用于更新客户基本信息表中的年龄分组字段。通过计算身份证号或生日信息得出的实际年龄,并依据年龄范围进行分组。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建存储过程:

 

create or replace procedure PD_SEXPY(agegr in varchar2,minage in number,maxage in number)

is

begin
          update CUST_BASIC_INFO set AgeGroup = agegr where 
    
  case
     when length(card_no) = 18 then
                       ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(to_date(substr(card_no, 7, 8), 'yyyy-MM-dd'),
                                       'yyyyMMdd')) / 10000)
                when length(card_no) = 15 then
                         ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(to_date('19' || substr(card_no, 7, 6),
                                               'yyyy-MM-dd'),
                                       'yyyyMMdd')) / 10000)
                  when length(card_no) != 18 and length(card_no) != 15 and BIRTHDAY != null
                     then ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(BIRTHDAY,
                                       'yyyyMMdd')) / 10000)
                       
                     end 
 
 
  in (select cu1.cuage from (select 
  case
     when length(cu.card_no) = 18 then
                       ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(to_date(substr(cu.card_no, 7, 8), 'yyyy-MM-dd'),
                                       'yyyyMMdd')) / 10000)
                when length(cu.card_no) = 15 then
                         ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(to_date('19' || substr(cu.card_no, 7, 6),
                                               'yyyy-MM-dd'),
                                       'yyyyMMdd')) / 10000)
                  when length(cu.card_no) != 18 and length(cu.card_no) != 15 and BIRTHDAY != null
                     then ceil((to_char(sysdate, 'yyyyMMdd') -
                              to_char(BIRTHDAY,
                                       'yyyyMMdd')) / 10000)
                       
                     end as cuAge

 from cust_basic_info cu)cu1 where cu1.cuage>=minage and cu1.cuage<=maxage);
         
        commit;
 
end PD_SEXPY;

mapper:

	
	public void getPD_SEXPY(@Param("map") Map<String, Object> map);

mapper xml:

<select id="getPD_SEXPY" statementType="CALLABLE"
		parameterType="map" >
	 	<![CDATA[
			{call PD_SEXPY(#{map.agegroup,mode=IN,  jdbcType=VARCHAR},
			#{map.agestage,mode=IN,  jdbcType=INTEGER},
			#{map.agestageend,mode=IN,  jdbcType=INTEGER})}
		]]>
	</select>

service:

		String agegroup = "1";
		Integer agestage = "18";
		Integer agestageend = "24";
		
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("agegroup", agegroup);
			map.put("agestage", agestage);
			map.put("agestageend", agestageend);
			custBasicInfoMapper.getPD_SEXPY(map);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值