On 25-7-2014 15:23, Alex Peshkoff wrote: >> JDBC also has createStatement which creates a statement handle that can >> be used to execute arbitrary SQL statements *without* parameters. > > And it also can create CallableStatement to execute procedures. FB3 > always creates generic statement (one can work with unknown SQL > operator), next you may ask that object can it produce cursor or not, > does it have output parameters (i.e. procedure call) or may be it's DDL > or START TRANSACTION. Next you invoke proper function in that object to > run it.
You don't need to use CallableStatement for stored procedures, it just provides extra features for stored procedures (eg support for OUT and INOUT parameters). The way stored procedures in Firebird work doesn't entirely match with the requirements in JDBC, and as currently implemented in Jaybird it is probably not entirely correct. For example most stored procedure languages support a single return value and multiple output variables (either as OUT or INOUT) and can produce (one or multiple) result sets. JDBC is defined along those expectations. The fact that in Firebird there are multiple return values which either behave somewhat as an OUT parameter (executable), or as the column of a result set (selectable) is an endless source of joy, I mean confusion ;) The separation between Statement and PreparedStatement (and CallableStatement) in JDBC may seem like overkill, but if you are executing statements without parameters and you are only executing them once, it is overhead to have to prepare a query before you can execute. As I understand the execute immediate functionality in Firebird, it is limited in that it can only be used to execute statements that don't produce a result set (or have a singleton result), and you can't ask for things like update counts. So currently Jaybird simply prepares and execute for its Statement implementation, but a single shot prepare-and-execute would actually be nice ;) The checks if you are executing in the right way is left to the difference between executeUpdate (should at most produce an update count), executeQuery (should produce a single result set) or execute (everything works: allows for multiple update counts, multiple result sets, etc). If the query does not meet those expectations the driver (or the database) should raise an exception (which Jaybird currently doesn't do). Mark -- Mark Rotteveel ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel