0
對於嵌套表我按照以下方式完成了它? 這是pl/sql存儲過程。如何將pl/sql的輸出關聯數組傳遞給java?
CREATE or REPLACE PROCEDURE TEST(
activationStartDate IN DATE,
activationEndDate IN DATE,
deActivationStartDate IN DATE,
deActivationEndDate IN DATE
Out_Entity OUT TEST1.RefCsr
)
AS
FirstNameListTable LIST_TABLE;
{--COMMENT :LIST_TABLE is nested table :create or replace TYPE "LIST_TABLE" as table of varchar2(20);-----Nested Table Declaration
/
}
totalSameFirstName NUMBER;
j NUMBER := 1;
BEGIN
SELECT first_name BULK COLLECT INTO FirstNameListTable FROM Employee where start_date between activationStartDate AND activationEndDate
MINUS
SELECT first_name FROM Employee where start_date between deActivationStartDate AND deActivationEndDate
OPEN Out_Entity FOR SELECT * FROM TABLE(
CAST (
FirstNameListTable AS LIST_TABLE
)
) Nos;
END;
/
我JavaCode是
--First getConnection
--prepare sql string : sql = "{ Call Test(?,?,?,?,?) } ";
--Use prepareCall function on Connection object and passed this sql string and retrived CallableStatement class object.
stmt.setTimestamp(1,activationStartDate);
stmt.setTimestamp(2,activationEndDate);
stmt.setTimestamp(3,deActivationStartDate);
stmt.setTimestamp(4,deActivationEndDate);
stmt.registerOutParameter(5,-10);
stmt.execute();
List result = new ArrayList();
ResultSet rs = (ResultSet)stmt.getObject(5);
int i=0;
while (rs.next())
{
System.out.println(i+". "+rs.getString(1));
i++;
}
那麼如果我想從員工選擇多列,並傳遞給我的javaCode ......如何我javaCode和PL/SQL會看喜歡?
此問題似乎是你也是。 http://stackoverflow.com/questions/457933/creating-package-level-associative-array-in-java – Ollie