首頁  >  文章  >  資料庫  >  ibatis调用Oracle中的function

ibatis调用Oracle中的function

WBOY
WBOY原創
2016-06-07 17:20:341105瀏覽

ibatis调用Oracle中的function,先做这样的假设,学生的学号和姓名可以唯一确定一个学生。Oracle存储过程

先做这样的假设,学生的学号和姓名可以唯一确定一个学生。

Oracle存储过程

create or replace function get_stu_birth(vid varchar,vname varchar) return date is
  vbirth   date;
  n          number;

begin
 select count(*),birth into n,pbirth from student where id = vid and name = vname;
 if n>0 then
  vbirth:=pbirth;
 else
  null;
 end if;
 return vbirth;
end;

StudentSqlMapper.xml


 
  
  
  
 

 
 
         {? = call get_stu_birth(?,?) }
    ]]>
 

 


Student.java

Map mapIn = new HashMap();
mapIn.put("vid", "100");
mapIn.put("vname", "xy");
mapIn.put("vbirth", "");
baseDao.selectObject("studentMapper.stuproc", mapIn);
Date birth = DateUtil.toDate(mapIn.get("vbirth").substring(0, mapIn.get("vbirth").length() - 2), "yyyy-mm-dd hh24:mi:ss");

在执行完这句话之后baseDao.selectObject("studentMapper.stuproc", mapIn),mapIn.get("vbirth")的值已经被装进去了。

格式如2012-1-1 12:12:12.0,所以要处理一下。

linux

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn