0

I have below java code:

void insertRatings(String Rname , String uName ,BigDecimal rating , String rDate) throws SQLException, ParseException
    {
        CallableStatement cs = conn.prepareCall("? = call insertRating(?,?,?,?) ");

        cs.registerOutParameter(1, Types.INTEGER);
        cs.setString(2, Rname);
        cs.setString(3, uName);
        cs.setBigDecimal(4, rating);
        cs.setDate(5,new Date(new SimpleDateFormat("dd/MM/yyyy").parse(rDate).getTime()));


        cs.executeQuery();

        System.out.println("Output recived from fucntion :: "+cs.getInt(1));

    }

And SQL function is:

create or replace function insertRating(Rname varchar2(100),uName varchar2(100),rating Number,
rDate Date) return Integer is

The SQL function works as expected. However, when I run the java code I get the below error for cs.executeQuery();

Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement

What did I miss?

1
  • Why not take a look at the documentation? Commented Feb 4, 2018 at 17:42

1 Answer 1

2

I got the solution:

CallableStatement cs = conn.prepareCall(" { ? = call insertRating(?,?,?,?) }");

'{}' is what I was missing.

I hope it will someone.

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.