Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

I have a method in Dao Class that returns List<Object[]> back and I am using named Query

public List<Object[]> getListByCustomer(Session session, int customerId, List<Integer> strIds) {
  Query namedQuery = session.createSQLQuery(QueryConstants.EXPORT);
  namedQuery.setParameter("customer", customerId);
  namedQuery.setParameter("stringId", strIds);
  List<Object[]> objects = namedQuery.list();
  return objects;
}

I want to pass List<Integer> strIds in stringId into the named query as follows :

public class QueryConstants {
  public static final String EXPORT = 
    "SELECT sv.NAME, sv.TYPE, sv.CLIENT_ADDRESS, sv.NAME_REDUNDANT, sv.DEPARTURE_DATE, s1.CODE,sv.STATE, sv.CODE "
    + "FROM VIEW sv, PROCESS p1, SET s1 " 
    + "WHERE sv.R_ID = p1.R_ID and p1.ISSUER_ID = s1.USER_ID and sv.CUSTOMER_ID = :customer and sv.R_ID IN (:stringId)";
}

But I get ORA-00932: inconsistent datatypes: expected NUMBER got BINARY.

Also when I remove sv.R_ID IN (:stringId) from the query it works fine and when I pass Integer(strIds) instead of List<Integer> strIds into the query it works fine.

I'm using Oracle 10g.

like image 917
techGaurdian Avatar asked Apr 22 '14 11:04

techGaurdian


People also ask

What does ora-00932 error code mean?

ORA-00932: inconsistent datatypes: expected NUMBER got BINARY. I want to add a image to a database (oracle). When I run this code, I got java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY.

What are the symptoms of ora-00932 when trying to use dynamic select?

The symptoms of this bug consist of ORA-00932 when trying to use a dynamic select statement Though it was functional in 9.2.0.4, it does fail in 10g. ORA-00932 is caused by the statement you were intending to use with the Native Dynamic SQL in which the amount of items have to be the same in the SELECT and INTO lists.

Why do I get binary error when I set a parameter?

This is a very misleading error, and may root from different causes, for me I was setting a parameter that it was supposedly a number but at runtime it was setting null, hence it was binary. On a separate occasion got this error due to bean creation error in spring and was not setting the parameter correctly as well.


1 Answers

This is a very misleading error, and may root from different causes, for me I was setting a parameter that it was supposedly a number but at runtime it was setting null, hence it was binary. On a separate occasion got this error due to bean creation error in spring and was not setting the parameter correctly as well.

like image 163
mel3kings Avatar answered Sep 21 '22 16:09

mel3kings