• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Callable statement vs prepared statement

 
fahad siddiqui
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Callable is used to call stored procedures specifically.
We can call stored procedures using Prepared Statement also using sql string as
<code>
{call sp_name (?,?)}
</code>

Why should we choose one over the other? What are the advantages enjoyed?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an ORM question. Moving...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34695
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by fahad siddiqui:
Why should we choose one over the other? What are the advantages enjoyed?

If you have a stored procedure, you should use CallableStatement. A PreparedStatement is not guaranteed to work across all databases and drivers. This makes your code less robust. While you probably aren't changing databases with stored procs, you are likely to upgrade the driver.

Oracle fixed a bug in getDate() in Oracle 10 which caused legacy code to break that was relying on a side effect. If you follow the spec (or intent of the API), you protect your code against future changes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic