//reset the activation to clear warnings
//and clear existing result sets in case this has been cached
a.reset();
a.setMaxRows(maxRows);
ResultSet resultsToWrap =
ps.execute(a, forMetaData, timeoutMillis);
addWarning(ps.getCompileTimeWarnings());
addWarning(a.getWarnings());
if (resultsToWrap.returnsRows()) {
// The statement returns rows, so calling it with
// executeUpdate() is not allowed.
if (executeUpdate) {
throw StandardException.newException(
SQLState.LANG_INVALID_CALL_TO_EXECUTE_UPDATE);
}
EmbedResultSet lresults = factory.newEmbedResultSet(getEmbedConnection(), resultsToWrap, forMetaData, this, ps.isAtomic());
results = lresults;
// Set up the finalization of the ResultSet to
// mark the activation as unused. It will be
// closed sometime later by the connection
// outside of finalization.
if (a.isSingleExecution())
lresults.singleUseActivation = a;
updateCount = -1L;
retval = true;
}
else {
// Only applipable for an insert statement, which does not return rows.
//the auto-generated keys resultset will be null if used for non-insert statement
if (a.getAutoGeneratedKeysResultsetMode() && (resultsToWrap.getAutoGeneratedKeysResultset() != null))
{
resultsToWrap.getAutoGeneratedKeysResultset().open();
autoGeneratedKeysResultSet = factory.newEmbedResultSet(getEmbedConnection(),
resultsToWrap.getAutoGeneratedKeysResultset(), false, this, ps.isAtomic());
}
updateCount = resultsToWrap.modifiedRowCount();
results = null; // note that we have none.
int dynamicResultCount = 0;
if (a.getDynamicResults() != null) {
dynamicResultCount =
processDynamicResults(a.getDynamicResults(),
a.getMaxDynamicResults());
}
resultsToWrap.close(); // Don't need the result set any more
// executeQuery() is not allowed if the statement
// doesn't return exactly one ResultSet.
if (executeQuery && dynamicResultCount != 1) {
throw StandardException.newException(