How do you call a stored-function (oracle 8i) from Java code?
Exaple: I wrote sf_Days(...) function which returns a number.
How does a Java-code program call my function?
Printable View
How do you call a stored-function (oracle 8i) from Java code?
Exaple: I wrote sf_Days(...) function which returns a number.
How does a Java-code program call my function?
You could fine some samples in $ORACLE_HOME/jdbc/demo/samples.
This is what the developer is trying to use (NO SUCCESS)
...why?:
CallableStatement cs = db.getConnection().prepareCall("{call SF_DAYS(?,?,?)}");
cs.setString(1,"US");
cs.setDate(2,new Date(2000,9,9));
cs.setString(3,"B");
// cs.registerOutParameter(4, java.sql.Types.INTEGER);
cs.execute();
int nDays = 0;
cs.getInt(nDays);
My function is:
create or replace function sf_days(CountryCode varchar2,ProcessDate date,Daystype varchar2)
return number
...
Thanks
CallableStatement cstmt = conn.prepareCall("{? = CALL balance}");
cstmt.registerOutParameter(1,Type.FLOAT);
cstmt.setInt(2,acctno);
cstmt.executeUpdate();
float acctBal = cstmt.getFloat(1);
OR
u can directly execute query
for e.g
ur function name is fun_checkaccess and u r passing one parameter
u can write query like this
select fun_checkaccess(inputparameter) from dual;