Reputation: 21893
StringBuffer sql = new StringBuffer("{ call ? := mailmerge_package.getLetters(?, ?, ?)}");
I know it's like an sql statement but theres no such thing as 'call' in SQL.
Can someone explain to me what it means and how does it come to be understood by Java
EDIT:
import oracle.jdbc.driver.OracleTypes;
//omitted code
CallableStatement cs = null;
ResultSet rs = null;
StringBuffer sql = new StringBuffer("{ call ? := mailmerge_package.getLetters(?, ?, ?)}");
try {
cs = conn.prepareCall(sql.toString());
cs.registerOutParameter(1, OracleTypes.CURSOR);
DAOUtils.setLong(cs, 3, checklistAnsMastId);
DAOUtils.setLong(cs, 2, workEntityId);
cs.setLong(4, patientId);
DAOUtils.setLong(cs, 5, encounterId);
cs.setString(6, encounterType);
cs.execute();
rs = (ResultSet)cs.getObject(1);
Upvotes: 1
Views: 205
Reputation: 231671
{call <<procedure name>>}
is a SQL escape sequence. Basically, since different databases have different syntax for how to call a user-defined procedure and different databases have different built-in functions for various things like common date/ time functions, JDBC drivers implement a number of escape sequences where the driver translates a generic specification (i.e. {call <<procedure name>>}
) and expands that to be the database-specific syntax. There are various other escape sequences for things like outer joins, date literals, and string functions that can be useful if you're trying to write database agnostic code.
FYI, these escape sequences were originally defined in the ODBC API and then adopted by JDBC so you may find more documentation related to ODBC than JDBC.
Upvotes: 3
Reputation: 32681
This looks like SQL you can pass to Oracle.
If so then this could be used to call an Oracle function mailmerge_package.getLetters which returns a value. That value is parsed by JDBC and the Db layer to replace the first ?, this can be read into a Java variable. the Oracle function takes 3 parameters (the 3 ? in parentheses)
Upvotes: 6
Reputation: 13174
It is call to an stored procedure of a database. But which database, I can't tell from this code.
Upvotes: 2