Create or replace package my_steel_soft As -- Type of the dataset returned by the Stored Procedure Type returndataset is ref cursor; End my_steel_soft; Create or replace function BB (begindate in varchar2) Return my_steel_soft.returndataset As Acursor my_steel_soft.returndataset; Begin Open acursor for select * From v_out_orderqry t Where T. dorderdate> = begindate; -- And T. dorderdate <enddate; -- And T. ssalerguid = orgguid -- Or T. sbuyguid = orgguid; Return acursor; End BB; /** * Testfun. Java * Create on 2007-5-23 * Copyright 2010 mysteelsoft All Rights Reserved. */ Package com. test; Import java. SQL. callablestatement; Import java. SQL. connection; Import java. SQL. drivermanager; Import java. SQL. resultset; Import java. SQL. sqlexception; Public class testfun { Public static void main (string [] ARGs) {
Connection connection = NULL; Try { Class. forname ("oracle. JDBC. Driver. oracledriver "); } Catch (classnotfoundexception e ){ System. Out. println ("database driver class not found "); } Try { Resultset rs = NULL; String servername = "192.168.18.21 "; String portnumber = "1521 "; String SID = "eTrade "; String url = "JDBC: oracle: thin: @" + servername + ":" + portnumber + ":" + Sid; String username = "Developer "; String Password = "mysteelsoft "; Connection = drivermanager. getconnection (URL, username, password ); Callablestatement cstmt = NULL ;; Cstmt = connection. preparecall ("{? = Call BB (?)} "); // Cstmt = connection. preparecall ("? = Call eTrade. BB (?); "); Cstmt. registeroutparameter (1, Oracle. JDBC. oracletypes. cursor ); Cstmt. setstring (2, "2006-12-12 "); System. Out. println (cstmt ); Cstmt.exe cute (); Rs = (resultset) cstmt. GetObject (1 ); If (RS! = NULL ){ While (Rs. Next ()){ System. Out. Print (Rs. getstring (1) + ""); System. Out. Print (Rs. getstring (2) + ""); System. Out. println (Rs. getstring (3 )); } } Cstmt. Close (); Connection. Close (); } Catch (sqlexception e ){ E. printstacktrace (); } } } /** * Testfun. Java * Create on 2007-5-23 * Copyright 2010 mysteelsoft All Rights Reserved. */ Package com. test; Import java. SQL. callablestatement; Import java. SQL. connection; Import java. SQL. drivermanager; Import java. SQL. resultset; Import java. SQL. sqlexception; Import javax. SQL. rowset. cachedrowset; Import com. Sun. rowset. cachedrowsetimpl; Public class testfun { Public static void main (string [] ARGs) {
Connection connection = NULL; Try { Class. forname ("oracle. JDBC. Driver. oracledriver "); } Catch (classnotfoundexception e ){ System. Out. println ("database driver class not found "); } Try { Cachedrowset CRS = new cachedrowsetimpl ();
Resultset rs = NULL; String servername = "192.168.18.21 "; String portnumber = "1521 "; String SID = "eTrade "; String url = "JDBC: oracle: thin: @" + servername + ":" + portnumber + ":" + Sid; String username = "Developer "; String Password = "mysteelsoft "; Connection = drivermanager. getconnection (URL, username, password ); Callablestatement cstmt = NULL ;; Cstmt = connection. preparecall ("{? = Call BB (?)} "); Cstmt. registeroutparameter (1, Oracle. JDBC. oracletypes. cursor ); Cstmt. setstring (2, "2006-12-12 "); Cstmt.exe cute (); System. Out. println (cstmt ); Rs = (resultset) cstmt. GetObject (1 ); CRS. populate (RS );
If (CRS! = NULL ){ While (CRS. Next ()){ System. Out. Print (CRS. getstring ("sguid") + ""); System. Out. Print (CRS. getstring ("sorderid") + ""); System. Out. println (CRS. getstring ("ssalerguid ")); } } Cstmt. Close (); Connection. Close (); } Catch (sqlexception e ){ E. printstacktrace (); } } } |