---
title: "Ibatis中如何调用oracle存储的函数?"
author: "rainbow686"
date: "2007-06-22T17:01:30Z"
tags: []
categories: ["企业架构"]
slug: "ibatis-oracle"
draft: false
lastmod: "2007-06-22T17:01:30Z"
id: 93212
url: "https://rainbow686.iteye.com/blog/93212"
---

Ibatis中如何调用oracle存储的函数  
如在oracle中有个package叫做PCK\_VIEW，在PCK\_VIEW里面有个F\_GET\_SITESNAPSHOT\_TIME的函数有一个varchar2参数  
\-------------------------------------------  
  function F\_GET\_PARTNER\_LIST(p\_tmp varchar2)  
    return RecordSet  
  is  
    l\_rs RecordSet;  
  begin  
    open l\_rs for select partner from T\_PARTNER  order by UPPER(partner) asc;   
    return l\_rs;  
  end F\_GET\_PARTNER\_LIST;  
\-------------------------------------------  
在ibatils里面配置调用是{ call PCK\_VIEW.F\_GET\_SITESNAPSHOT\_TIME(?) }  
我确定参数都配置好了，但是调用的时候还是报错啊  
\-------------------------------------------  
\--- The error occurred in com/phoenixtv/stat/dao/ibatis/sql/realtime.xml. --- The error occurred while applying a parameter map. --- Check the stat.realtime.pm\_in\_getSiteSnapshotTime. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00221: 'F\_GET\_SITESNAPSHOT\_TIME' is not a procedure or is undefined ORA-06550: line 1, column 7:  
\-------------------------------------------  
怎么回事，明明数据库有这个函数啊？  
但是我在jdbc中这段代码确可以调用  
\-------------------------------------------  
            Class.forName("oracle.jdbc.driver.OracleDriver");    
            conn =DriverManager.getConnection("jdbc:oracle:thin:@111.111.111.111:1521:stat","pass","pass");  
             

            //conn = DBConnection.ins.getConn("jdbc/StatDB");sdf.format(new Date())+1  
            //conn = DBConnection.ins.getConn("statistic");

            cs = conn.prepareCall("{? = call PCK\_VIEW.F\_GET\_SITESNAPSHOT\_TIME(?)}");  
            cs.registerOutParameter(1, OracleTypes.CURSOR);  
            cs.setString(2,"");  
            cs.execute();  
            rs =(ResultSet) cs.getObject(1);  
\--------------------------------------------