一
create table BOOK
(
BOOKID VARCHAR
BOOKNAME VARCHAR
PUBLISHER VARCHAR
PRICE VARCHAR
)
CREATE OR REPLACE PACKAGE pkg_test
AS
TYPE myrctype IS REF CURSOR;
PROCEDURE get (p_id VARCHAR
END pkg_test;
/
CREATE OR REPLACE PACKAGE BODY pkg_test
AS
PROCEDURE get (p_id VARCHAR
IS
sqlstr VARCHAR
BEGIN
p_str :=
IF p_id =
OPEN p_rc FOR
SELECT *
FROM BOOK;
ELSE
sqlstr :=
from BOOK where BOOKID=:w_id
OPEN p_rc FOR sqlstr USING p_id;
END IF;
END get;
END pkg_test;
/
在這裡我們建立了一個輸入參數
(注
二
/*
* 創建日期:
*/
package JDBC;
/**
* 作者:may
* 時間:
*/
import java
import oracle
public class proctest {
public static void main(String[] args) {
proctest pc = new proctest();
pc
}
String sDBDriver=
String sConnStr=
Connection connect=null;
ResultSet rs = null;
public proctest(){
try{
Class
}
catch(ClassNotFoundException e){
System
}
}
public ResultSet ShowContent()
{
try{
connect = DriverManager
CallableStatement stmt = connect
stmt
stmt
stmt
stmt
rs = ((OracleCallableStatement) stmt)
ResultSetMetaData rsmd = rs
int numberOfColumns = rsmd
String str = stmt
System
System
//列出結果集中的記錄
ResultSetMetaData md = rs
int nColumns = md
for (int i=
System
if(i==
}
while (rs
for(int i=
System
}
}
}
catch(SQLException ex){
System
}
return rs;
}
}
輸出結果為
第二個參數為:Hello
結果集列數
BOOKID BOOKNAME PUBLISHER PRICE
From:http://tw.wingwit.com/Article/program/Oracle/201311/18612.html