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: 2882
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: 7901
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: 26766
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 Nov 09 17:11:25 CST 2024