Home > Database > Mysql Tutorial > body text

ibatis调用Oracle中的function

WBOY
Release: 2016-06-07 17:20:34
Original
1104 people have browsed it

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!