Statements
Statements are used to create ResultSets
or to update the database. The executeQuery()
method creates new ResultSets
. The following code snippet shows how the new ResultSet
is created. There can be only one ResultSet
at a time.
Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); Reference< XResultSet > xRS = NULL; // create a resultset as result of executing the sql statement // something needs to be done here :-) m_xResultSet = xRS; // we nedd a reference to it for later use return xRS; }
The executeUpdate()
methods only return the rows that were affected by the given SQL statement. The last method execute returns true when a ResultSet
object is returned when calling the method getResultSet()
, otherwise it returns false. All other methods have to be implemented.
PreparedStatement
The PreparedStatement
is used when an SQL statement should be executed more than once. In addition to the statement class, it must support the ability to provide information about the parameters when they exist. For this reason, this class must support the com.sun.star.sdbc.XResultSetMetaDataSupplier interface and also the com.sun.star.sdbc.XParameters interface to set values for their parameters.
Result Set
The ResultSet
needs to be implemented. For the first step, only forward ResultSets
could be implemented, but it is recommended to support all ResultSet
methods.
Content on this page is licensed under the Public Documentation License (PDL). |