create or replace function sum (n1 in number,n2 in number) return number is temp number(8); begin temp :=n1+n2; return temp; end; /
import java.sql.*; class CallableStatementFunction { public static void main(String args[])throws Exception { try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("....."); CallableStatement cs=con.prepareCall("{?= call sum(?,?)}"); cs.setInt(2,10); cs.setInt(3,20); cs.registerOutParameter(1,Types.INTEGER); cs.execute(); System.out.println("10+20 =" + cs.getInt(1)); cs.close(); con.close(); } catch(Exception e) { System.out.println(e); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)