Home » SQL & PL/SQL » SQL & PL/SQL » Bind Mismatch Issue (Oracle 10g)
icon2.gif  Bind Mismatch Issue [message #431364] Tue, 17 November 2009 03:06 Go to next message
sumitbhatnagar007
Messages: 2
Registered: November 2009
Junior Member
Hi,
I received a mail from our DBA saying that below query always reparsed by Oracle due to "bind mismatch" problem although we are using bind variables.

Code is -

There are 2 types of code which we used to insert data into tables.
Code1 with bind variables -


Code:
String hqlUpdate = "update " + boSource + " a set tibStatus = :loadStatusString where tibStatus = :intermediateStatusString and "+selectMaxOf +" from " + boSource
+ " where tibStatus = a.tibStatus " + sqlkeyCriteria + ")";
HashMap hParamMap = new HashMap();
hParamMap.put("loadStatusString", "LOAD");
hParamMap.put("intermediateStatusString", "INTR");
objectPS.executeQuery(hqlUpdate, hParamMap);
objectPS.flush();



Code2 without bind variables -


Code:
private void logErrorInDB(BOErrorLog objBOErrorLog, String userCode)
{
logger.logInfo("logErrorInDB", "Entering the method");
objBOErrorLog.setCreatedBy(userCode);
objBOErrorLog.setCreatedOn(new Date());
objBOErrorLog.setModifiedBy(userCode);
objBOErrorLog.setModifiedOn(new Date());
objectPS.saveOrUpdate(objBOErrorLog);
logger.logInfo("logErrorInDB", "Exiting the method");
}



generated SQL - Provided by DBA


Code:
insert into ERROR_LOG (OBJECT_CODE, OBJECT_KEY, PROCESS_CODE, ERROR_CODE, DESCRIPTION, CREATED_BY, CREATED_ON, MODIFIED_BY, MODIFIED_ON, id) values (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10);


Please let me know why i am getting bind mismatch with bind variables itself? Or is there any other way to rewrite the above code to get rid of this problem.
Thanks in advance.
Re: Bind Mismatch Issue [message #431366 is a reply to message #431364] Tue, 17 November 2009 03:11 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
What database and version are you using?
Re: Bind Mismatch Issue [message #431368 is a reply to message #431366] Tue, 17 November 2009 03:17 Go to previous messageGo to next message
sumitbhatnagar007
Messages: 2
Registered: November 2009
Junior Member
I am using Oracle 10g and hibernate 3
Re: Bind Mismatch Issue [message #431500 is a reply to message #431368] Tue, 17 November 2009 12:51 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Check if the datatypes in your mapping file (.hbm.xml) comcur witht the datatypes in your table.
Re: Bind Mismatch Issue [message #431502 is a reply to message #431364] Tue, 17 November 2009 13:14 Go to previous message
BlackSwan
Messages: 25033
Registered: January 2009
Location: SoCal
Senior Member

A very nice response from mishaalsy in URL below

http://www.dbforums.com/oracle/1650404-bind-mismatch-issue.html

Previous Topic: Constraints
Next Topic: Unique constraint error
Goto Forum:
  


Current Time: Sat Dec 03 12:28:36 CST 2016

Total time taken to generate the page: 0.06945 seconds