0

How should I call an Oracle function from Java? The function is supposed to return a number.

        CallableStatement cstmt = mJConn.prepareCall("{? = call fnd_request.submit_request( application => 'FND', program => 'JAVACONINSERT', description => 'CSV to DB Insert via Java' ,start_time => sysdate ,sub_request => FALSE, argument1 => '/home/TEST/java/t1.txt')}");
            cstmt.registerOutParameter(1, Types.INTEGER);
            cstmt.executeUpdate();
            int reqId = cstmt.getInt(1);
        System.out.println(reqId);          
5
  • what is the problem with your solution? Commented Feb 13, 2019 at 17:45
  • 1
    Are you trying to call an EBS function or a concurrent program? Commented Feb 13, 2019 at 17:56
  • 1
    plz give int reqId = cstmt.getInt(1); a try. (case sensitive!) Commented Feb 13, 2019 at 18:17
  • find_request is a PL/SQL package, yes? submit_request is a function in that package, yes? Note that a [PL/SQL] function is not the same as a [PL/SQL] procedure. Commented Feb 13, 2019 at 18:32
  • Yes its a Package.Function which returns number Commented Feb 14, 2019 at 10:53

1 Answer 1

1

Try replacing

String call = "{?= CALL Proc(?)}";

with

String call = "{CALL Proc(?, ?)}";

The former syntax is for calling a stored function, and the new one is for a stored procedure.

You can also to swap the order of the bind parameters :

cs.setString(1, "String");
cs.registerOutParameter(2, Types.INTEGER); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.