DAO調用Oracle帶自定義類型的存儲過程.

DAO調用Oracle帶自定義類型的存儲過程...


方法:

protected void initPreparedParamer(PreparedStatement stmt, KeyValue paramter) throws SQLException

的主要代碼:

TransVO vo = (TransVO) paramter.getValue();
    Connection conn=getCon(stmt);//從stmt獲取鏈接
    stmt.setInt(2, vo.getLineID());
    stmt.setInt(3, vo.getDirection());
    stmt.setString(4, vo.getTransTime());
    stmt.setInt(5, vo.getWeightTotal());
    stmt.setInt(6, vo.getVolumeTotal());
   
    String carStr=vo.getCars();
    String[] cars=carStr.split("--");
   
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("CARLIST",conn);//CARLIST是在Oracle中的自定義類型,原來這還一定要大寫...不大寫會報錯:java.sql.SQLException: 無效的名稱模式:oracle.carlist          

ARRAY array = new ARRAY(desc, conn , cars);
           ((OracleCallableStatement)getStmt(stmt)).setARRAY(1, array);//這裏一定要把stmt轉成OracleCallableStatement才能使用setARRAY方法

---------------------------------------------------------------------------------------------

不單這裏麻煩這種方式在JDBC鏈接方式下是沒有問題的。。。項目提交需要轉成JNDI連接方式。。。

結果暈掉了。。。鬱悶了一陣子。。。不知道大家有沒有注意到getStmt(stmt)方法。。。來看看下面這段。。。更詳細點

@Override
protected void initPreparedParamer(PreparedStatement stmt, KeyValue paramter) throws SQLException {
   String key = paramter.getKey();
  
   if(key.equals("insert")){
    CarVO vo =(CarVO)paramter.getValue();
    stmt.setString(1,vo.getCarType());
    stmt.setInt(2,vo.getWeight());
    stmt.setInt(3, vo.getVolume());
    stmt.setInt(4, vo.getState());
   
   }else if(key.equals("update")){
    CarVO vo =(CarVO)paramter.getValue();
    stmt.setString(1,vo.getCarType());
    stmt.setInt(2,vo.getWeight());
    stmt.setInt(3,vo.getVolume());
    stmt.setInt(4, vo.getState());
    stmt.setString(5,vo.getCarId());
   
   }else if(key.equals("delete")){
    logger.debug("in init delete...");
    String[] carids =(String[])paramter.getValue();
    logger.debug("carids length:"+carids.length);
    Connection conn=getCon(stmt);//從代理獲取鏈接...代理是什麼???一會看getCon方法的代碼
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("CARLIST", conn);
         ARRAY array = new oracle.sql.ARRAY(desc, conn , carids);
         ((OracleCallableStatement)getStmt(stmt)).setARRAY(1, array);
   }
}

getCon方法和getStmt方法是從BaseDAO類實現過來的...省事啊...大家都要用...呵呵

------------------------------------------------------------------------------------------------------------------

兩個方法的代碼:

public Connection getCon(PreparedStatement stmt){//換服務器需改這個方法
   Connection con;
   try{
   if(DBConfig.isDebug())//jdbc
    con=stmt.getConnection();
   else//jndi
   con=((org.apache.commons.dbcp.PoolableConnection)stmt.getConnection()).getInnermostDelegate();
   //其實從stmt中獲得連接非常簡單...stmt.getConnection就行啦...但是得到的Connection並不是Java.sql.Connection...而是PoolableConnection...所以...慘了...必須轉換成org.apache.commons.dbcp.PoolableConnection才能使用
   return con;
   }catch(SQLException e){
    e.printStackTrace();
    return null;
   }
  
}
public PreparedStatement getStmt(PreparedStatement stmt){//換服務器需改這個方法
  
   PreparedStatement statement;//傳進來的是stmt...但是返回的還是PreparedStatement...不是白做嗎...非也
   if(DBConfig.isDebug())//jdbc
    statement=stmt;
   else//jndi
    statement=((org.apache.commons.dbcp.DelegatingCallableStatement)stmt).getDelegate();//結果的stmt和傳進來的stmt是不同的...具體有什麼不同也不知道...但是不轉換就會報錯...老師說不清...網上沒資料

//不過要注意的是需要加載apache的dbcp包...因爲要用到DelegatingCallableStatement嘛...呵呵...我的服務器是Tomcat...數據庫是Oracle...所以這個就鬱悶了...如果要換服務器的話...就要修改這裏...還沒有想到比較好的方法...
  
   return statement;
  
}

————————————————————————————————————————————

這個方法在網上找了很久。。。大概花了2天時間才解決。。。呵呵。。。最後還是從一篇文章中得到的靈感。。。呵呵。。。謝謝文章的作者和熱情恢復的網友們。。。謝謝網絡。。。謝謝百度。。。文章如下。。。:::::::::::::::::

===========================================================================================

第一靈感來源

Hibernate 1.2.3 has built-in support for blobs. Hibernate natively maps blob columns to java.sql.Blob. However, it's sometimes useful to read the whole blob into memory and deal with it as a byte array.

One approach for doing this to create a new UserType as follows.

package mypackage;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Types;import java.sql.Blob;import cirrus.hibernate.Hibernate;import cirrus.hibernate.HibernateException;import cirrus.hibernate.UserType;public class BinaryBlobType implements UserType{public int[] sqlTypes(){return new int[] { Types.BLOB };}public Class returnedClass(){return byte[].class;}public boolean equals(Object x, Object y){return (x == y)|| (x != null&& y != null&& java.util.Arrays.equals((byte[]) x, (byte[]) y));}public Object nullSafeGet(ResultSet rs, String[] names, Object owner)throws HibernateException, SQLException{Blob blob = rs.getBlob(names[0]);return blob.getBytes(1, (int) blob.length());}public void nullSafeSet(PreparedStatement st, Object value, int index)throws HibernateException, SQLException{st.setBlob(index, Hibernate.createBlob((byte[]) value));}public Object deepCopy(Object value){if (value == null) return null;byte[] bytes = (byte[]) value;byte[] result = new byte[bytes.length];System.arraycopy(bytes, 0, result, 0, bytes.length);return result;}public boolean isMutable(){return true;}}

The BinaryBlobType will convert a blob into a byte array and back again.

Here's how to use it. First, define an entity that contains a byte[] property:

public class ImageValue{private long id;private image byte[];public long getId() { return id; }public void setId(long id) { this.id = id; }public byte[] getImage() { return image; }public void setImage(byte[] image) { this.image = image; }}

Then map a blob column onto the byte[] property:

<class name="ImageValue" table="IMAGE_VALUE"><id name="id/><property name="image" column="IMAGE" type="mypackage.BinaryBlobType"/></class>

Notes:

1) Blobs aren't cachable. By converting the blob into a byte array, you can now cache the entity.

2) This approach reads the whole blob into memory at once.

3) The above type is known to work for reading blobs out of the db. Other usage patterns might also work.

Comments (GK)

I changed isMutable() to return true, since an array is a mutable object.

The use of setBlob() will work on some drivers, but not all. I think its more portable to use setBytes() or even setBinaryStream().

comments (db)

db's comment above was right, setBlob() didn't work on Oracle, I used setBytes().

comments (Chad Woolley)

Below is a modified nullsafeset() that i needed to use to get it to work with tomcat 4.1.27 & oracle 8/9i - the normal calls don't work through the tomcat/dbcp connection pool wrapper objects... (this caused me great pain)

pls note that the setBytes() doesn't seem to work with oracle driver & hibernate

[email protected]

public void nullSafeSet(PreparedStatement st, Object value, int index)throws HibernateException, SQLException{if(st instanceof org.apache.commons.dbcp.DelegatingPreparedStatement &&((org.apache.commons.dbcp.DelegatingPreparedStatement)st).getDelegate()instanceof oracle.jdbc.OraclePreparedStatement){oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(((org.apache.commons.dbcp.PoolableConnection)st.getConnection()).getDelegate(), false, oracle.sql.BLOB.DURATION_SESSION);blob.open(BLOB.MODE_READWRITE);OutputStream out = blob.getBinaryOutputStream();try{out.write((byte[])value);out.flush();out.close();}catch(IOException e){throw new SQLException("failed write to blob" + e.getMessage());}blob.close();((oracle.jdbc.OraclePreparedStatement)((org.apache.commons.dbcp.DelegatingPreparedStatement)st).getDelegate()).setBLOB(index, blob);}else{st.setBlob(index, Hibernate.createBlob((byte[]) value));}}//and.. note the null check, oracle drivers return a null blob...public Object nullSafeGet(ResultSet rs, String[] names, Object owner)throws HibernateException, SQLException{final Blob blob = rs.getBlob(names[0]);return blob != null?blob.getBytes(1, (int)blob.length()):null;}

/ comments Vanitha

I had to use the user type to save pdfs as oraBLOBs in oracle 91 database. nullsafeSet

needed a sligh modification , or else ther was a classcastexception. Used oracle Blob instead of Hibernate Blob type and it works.

public void nullSafeSet(PreparedStatement st, Object value, int index)throws HibernateException, SQLException{oracle.sql.BLOB t_blob = oracle.sql.BLOB.createTemporary(((org.jboss.resource.adapter.jdbc.WrappedConnection) st.getConnection()).getUnderlyingConnection(),false, oracle.sql.BLOB.DURATION_SESSION);OutputStream t_out = null;t_blob.open(BLOB.MODE_READWRITE);t_out = t_blob.getBinaryOutputStream();try{t_out.write((byte[]) value);t_out.flush();t_out.close();}catch (IOException e){throw new SQLException("failed write to blob" + e.getMessage());}t_blob.close();st.setBlob(index, t_blob);}

</code>

===========================================================================================

其他靈感來源。。。資源嘛。。。沒人嫌多的。。。呵呵

今天在改公司管理系統的時候,因爲某個功能需要使用數組類型作爲IN參數調用存儲過程,看了看文檔發現有Varray、nested table,但Varray有個最多數量的限制,也只好用nested table了,於是引發一連串的問題。
環境:
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

apache-tomcat-6.0.16

Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
本來對Java這種據說很先進的東西就懵懵懂懂,索性就真的以爲他非常牛X。使用幾維數組作爲參數調用存儲過程還不是跟Set個String一樣那麼簡單,但其實我錯了,所以我也對java很失望,他遠不如想象中那麼XX。
Object arrInt[] = {0,1,2,3,4,5,6};
callStmt.SetObject(1, arrInt, Types.ARRAY);
要是想像上面這樣操作他就會拋個java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to oracle.sql.ARRAY,於是我知道java他不會自己轉,非得人工干預。但我突然發現自己很愚蠢,我都沒告訴他procedure參數的類型,即使可以轉過去又有個P用,百度了一下才知道得用下面的法子。
import oracle.sql.ARRAY; 
import oracle.sql.ArrayDescriptor; 

Connnection conn = DBConnManager.getConnection();
callStmt = conn.prepareCall(sql);
ArrayDescriptor arrDesc = ArrayDescriptor.createDescriptor("dbms_sql.Varchar2_Table", conn);
ARRAY arr = new ARRAY(arrDesc, conn, arrInt); 
執行一下,結果異常。我靠數據庫裏能用dbms_sql.Varchar2_Table聲明,他居然 java.sql.SQLException: 無效的名稱模式: DBMS_SQL.VARCHAR2_TABLE。我心想是不是得寫成SYS.dbms_sql.Varchar2_Table,結果還是一樣。再百度,人們說這樣不行,原因...不知道,但必須得自己定義類型纔可以。於是我不得不
create type numbertable as table of number;

ArrayDescriptor arrDesc = ArrayDescriptor.createDescriptor("numbertable", conn);
ARRAY arr = new ARRAY(arrDesc, conn, arrInt);
結果又來了個java.sql.SQLException: 無效的名稱模式: baby.numbertable。我無語還得百度!@#¥%....N久無果!但我發別人的碼的代碼裏這個類型都是大寫,於是我也寫成NUMBERTABLE。哈哈,果然不出那個異常了。但他NND又蹦個java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection出來。這下鬱悶了,莫非從DBCP拿出來的Connection跟OracleConnection不一樣。暈了,別介呀,我對java不懂!又search了半天,發現了一個UnWrapper,本以爲能把這個Wrapper給幹掉的,但搞了半天沒搞明白。過了XX時間,不知道是在哪國網站上看到有人
ArrayDescriptor arrDesc = ArrayDescriptor.createDescriptor("NUMBERTABLE", ((DelegatingConnection)conn).getDelegate()));
他們用着都好用,到我這((DelegatingConnection)conn).getDelegate()出來的Connection是個null,很鬱悶。後來又看到
public static Connection getNativeConnection(Connection con) throws SQLException {
if (con instanceof DelegatingConnection) {
   Connection nativeCon = ((DelegatingConnection) con).getInnermostDelegate();
//   For some reason, the innermost delegate can be null: not for a
//   Statement's Connection but for the Connection handle returned by the pool.
//   We'll fall back to the MetaData's Connection in this case, which is
//   a native unwrapped Connection with Commons DBCP 1.1.
   return (nativeCon != null ? nativeCon : con.getMetaData().getConnection());
}
return con;
}
可((DelegatingConnection) con).getInnermostDelegate();依然是null但con.getMetaData().getConnection());得到了一個OracleConnection,debug時看着eclipse variables的窗口心中一陣暗喜,該OK了吧!

哎,事實上最近一段時間總是事與願違,執行-又異常了!鬱悶,一次比一次鬱悶,一次比一次怪異!
java.lang.ClassCastException: oracle.jdbc.driver.OracleConnection cannot be cast to oracle.jdbc.OracleConnection 由於字符串太長搜都搜不到,想了好久,嘗試着各種各樣的方法!終於有一個次把tomcat/lib目錄classes12.jar刪掉,沒有異常,一切OK!但後來把classes12.jar又仍進去了,還正常的,代碼沒有一點變化!很是鬱悶,但既然問題沒了,也就懶得看了!

最後的代碼:
-----------------------------------------------------------------------------------
public static Connection getConnection() {
Connection con = null;
try {
   Context ic = new InitialContext();
   DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/yoyo");
   con = ds.getConnection();
} catch (Exception e) {
   System.out.println("**** error DataSource");
}
return con;
}
-----------------------------------------------------------------------------------
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import oracle.sql.ARRAY; 
import oracle.sql.ArrayDescriptor; 
import org.apache.tomcat.dbcp.dbcp.DelegatingConnection;
public class BussinessLog {
public static ArrayList<Comparable> CancelLog(String sLoginUser, Object[] arrLogID) 
{
ArrayList<Comparable> arrList = new ArrayList<Comparable>();
Connection conn = null;
CallableStatement callStmt = null;
String sql = null;
ArrayDescriptor arrDesc = null;

try 
{
   conn = DbConnectionManager.getConnection();
   sql = "{call P_CanceltLog(?,?,?,?)}";   
   callStmt = conn.prepareCall(sql);
   arrDesc = ArrayDescriptor.createDescriptor("NUMBERTABLE", getNativeConnection(conn));
   ARRAY arr = new ARRAY(arrDesc, getNativeConnection(conn), arrLogID); 
   callStmt.setString(1, sLoginUser);
   callStmt.setObject(2, arr, Types.ARRAY);
   callStmt.registerOutParameter(3, Types.VARCHAR);
   callStmt.registerOutParameter(4, Types.INTEGER);
   callStmt.execute();
   
   arrList.add(callStmt.getInt(4));
   arrList.add(callStmt.getString(3));
   return arrList;
} catch (Exception e) {
   System.out.println(e.toString());
} finally {
   DbAction.clear(conn, callStmt);
}
return arrList;
}

public static Connection getNativeConnection(Connection con) throws SQLException {
if (con instanceof DelegatingConnection) {
   Connection nativeCon = ((DelegatingConnection) con).getInnermostDelegate();
//   For some reason, the innermost delegate can be null: not for a
//   Statement's Connection but for the Connection handle returned by the pool.
//   We'll fall back to the MetaData's Connection in this case, which is
//   a native unwrapped Connection with Commons DBCP 1.1.
   return (nativeCon != null ? nativeCon : con.getMetaData().getConnection());
}
return con;
}
}
-----------------------------------------------------------------------------------
A.在這之前我還下載了最新的commons-dbcp-1.2.2.jar,但使用裏面DelegatingConnection時,con instanceof DelegatingConnection是false,看來tomcat裏出來的Connection就的配Tomcat\lib\tomcat-dbcp.jar裏的DelegatingConnection,還真是什麼槍打什麼鳥。

B.偶爾發現((DelegatingConnection) con).getInnermostDelegate();之所以返回null是因爲tomcat裏Context.Resource的accessToUnderlyingConnectionAllowed參數默認爲false所致,被設置成true之後是可以取到OracleConnection的.

哎,技術爛,沒事也就只能發發牢騷了! 

創建於:2008-05-24 04:49:08,修改於:2008-05-24 05:06:24,已瀏覽270次,有評論5條 

網友評論 
網友:Experiencing this problem 時間:2008-06-12 19:15:48 IP地址:212.44.43.★ 


Hi Aowken,

Hopefully you can speak English. I'm sorry but I don't understand Chinese.
For what I can see of your blog entry, you are describing the problem I've got.
I'm trying to get to the embeded Oracle connection from the connection given by the DBCP pool in Tomcat 5.5 and I've used your example code here, but I'm getting the error: con instanceof DelegatingConnection: false
I tried to use the tomcat-dbcp.jar instead of commons-dbcp-1.2.2.jar, but with no luck.
Unfortunately I cannot understand your comments in Chinese. Do you think you could advise me?

Thanks a lot,

Monica 



網友:aowken 時間:2008-06-13 05:12:52 IP地址:221.13.5.★ 


Hi Monica, I don't speak English well, but i got you. 
You can't use commons-dbcp-1.2.2.jar, must be tomcat-dbcp.jar. 
I downloaded Tomcat 5.5.26 and tried.

Environment: Windows XP sp2, MyEclipse 5.5.1, Tomcat 5.5.26, Java 1.5, Oracle 9.2.0.1.0

1.Create new web project in MyEclipse

2.Tomcat 
Placed ojdbc14.jar/nls_charset12.zip/classes12.jar to D:\apache-tomcat-5.5.26\common\lib

server.xml----------------------------------------------------------------------------
<Context path="/demo" docBase="F:\Workspace\Eclipse\demo\WebRoot" debug="5" reloadable="true" >
<Resource name="jdbc/demo" auth="Container" type="javax.sql.DataSource" 
maxActive="100" maxIdle="30" maxWait="10000" 
username="system" password="system"   
driverClassName="oracle.jdbc.driver.OracleDriver" 
url="jdbc:oracle:thin:@127.0.0.1:1521:ora92"/>
</Context>

3.Project

WEB-INF/web.xml ----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/demo</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
</resource-ref> 
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

Code---------------------------------------------------------------------------------
package com.demo.database;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

import org.apache.tomcat.dbcp.dbcp.DelegatingConnection;

public class dao {

public String GetCurrentTime() 
{
   Connection conn = null;
   CallableStatement callStmt = null;
   String sql = null;
   ArrayDescriptor arrDesc = null;
  
   String CurrentTime = null;
   Object[] arrObj = {0,1,2,3,4,5};
   try 
   {
    Context ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/demo");
    conn = ds.getConnection();
   
    sql = "{call SP_DEMO(?,?)}";   
    callStmt = conn.prepareCall(sql);
    arrDesc = ArrayDescriptor.createDescriptor("NUMBERTABLE", getNativeConnection(conn));
    ARRAY arr = new ARRAY(arrDesc, getNativeConnection(conn), arrObj); 
    callStmt.setObject(1, arr, Types.ARRAY);
    callStmt.registerOutParameter(2, Types.VARCHAR);
    callStmt.execute();
   
    CurrentTime = callStmt.getString(2);
    callStmt.close();
    conn.close();
   } catch (Exception e) {
    System.out.println(e.toString());
   }
  
   return CurrentTime;
}

public Connection getNativeConnection(Connection con) throws SQLException {

   if (con instanceof DelegatingConnection) {
    Connection nativeCon = ((DelegatingConnection) con).getInnermostDelegate();

//   For some reason, the innermost delegate can be null: not for a
//   Statement's Connection but for the Connection handle returned by the pool.
//   We'll fall back to the MetaData's Connection in this case, which is
//   a native unwrapped Connection with Commons DBCP 1.1.

    return (nativeCon != null ? nativeCon : con.getMetaData().getConnection());
   }
   return con;
}
}

index.jsp----------------------------------------------------------------------------
<%@ page language="java" pageEncoding="utf-8"%>
<jsp:useBean id="demo" class="com.demo.database.dao" scope="page" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>My JSP 'index.jsp' starting page</title>
</head>

<body>
    This is my JSP page. <br>
    Current time : <%=demo.GetCurrentTime() %>
</body>
</html>

Java Build Path----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="com.genuitec.eclipse.j2eedt.core.J2EE14_CONTAINER"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/naming-factory-dbcp.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/commons-el.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/jasper-compiler.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/jasper-compiler-jdt.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/jasper-runtime.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/jsp-api.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/naming-factory.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/naming-resources.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/classes12.jar"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/nls_charset12.zip"/>
<classpathentry kind="lib" path="D:/apache-tomcat-5.5.26/common/lib/ojdbc14.jar"/>
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
</classpath>
=================================================================================================
Hopefully can help you. Good Luck!!! 



網友:aowken 時間:2008-06-13 05:15:07 IP地址:221.13.5.★ 


Oracle -------------------------------------------------------------------------------------
create or replace type NumberTable as table of number;

create table demo
(
n number
);

create or replace procedure SP_DEMO 
(
v_IDTable    NUMBERTABLE,
v_msg out varchar2 

is
begin
for i in v_IDTable.first..v_IDTable.Last loop
   insert into demo values(i);
end loop;
v_msg := to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss');
commit;
return;
end SP_DEMO; 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章