Search in sources :

Example 11 with ResultInterface

use of org.h2.result.ResultInterface in project h2database by h2database.

the class ConstraintCheck method checkExistingData.

@Override
public void checkExistingData(Session session) {
    if (session.getDatabase().isStarting()) {
        // don't check at startup
        return;
    }
    String sql = "SELECT 1 FROM " + filter.getTable().getSQL() + " WHERE NOT(" + expr.getSQL() + ")";
    ResultInterface r = session.prepare(sql).query(1);
    if (r.next()) {
        throw DbException.get(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, getName());
    }
}
Also used : ResultInterface(org.h2.result.ResultInterface)

Example 12 with ResultInterface

use of org.h2.result.ResultInterface in project h2database by h2database.

the class ConditionExists method getValue.

@Override
public Value getValue(Session session) {
    query.setSession(session);
    ResultInterface result = query.query(1);
    session.addTemporaryResult(result);
    boolean r = result.hasNext();
    return ValueBoolean.get(r);
}
Also used : ResultInterface(org.h2.result.ResultInterface)

Example 13 with ResultInterface

use of org.h2.result.ResultInterface in project h2database by h2database.

the class JdbcPreparedStatement method executeUpdateInternal.

private int executeUpdateInternal() throws SQLException {
    closeOldResultSet();
    synchronized (session) {
        try {
            setExecutingStatement(command);
            ResultWithGeneratedKeys result = command.executeUpdate(generatedKeysRequest);
            updateCount = result.getUpdateCount();
            ResultInterface gk = result.getGeneratedKeys();
            if (gk != null) {
                int id = getNextId(TraceObject.RESULT_SET);
                generatedKeys = new JdbcResultSet(conn, this, command, gk, id, false, true, false);
            }
        } finally {
            setExecutingStatement(null);
        }
    }
    return updateCount;
}
Also used : ResultInterface(org.h2.result.ResultInterface) ResultWithGeneratedKeys(org.h2.result.ResultWithGeneratedKeys)

Example 14 with ResultInterface

use of org.h2.result.ResultInterface in project h2database by h2database.

the class JdbcDatabaseMetaData method hasSynonyms.

private boolean hasSynonyms() {
    Boolean hasSynonyms = this.hasSynonyms;
    if (hasSynonyms == null) {
        SessionInterface si = conn.getSession();
        if (si instanceof SessionRemote) {
            SessionRemote sr = (SessionRemote) si;
            int clientVersion = sr.getClientVersion();
            if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_17) {
                hasSynonyms = true;
            } else if (clientVersion <= Constants.TCP_PROTOCOL_VERSION_15) {
                hasSynonyms = false;
            } else {
                // 1.4.194-1.4.196
                CommandInterface c = sr.prepareCommand("CALL H2VERSION()", Integer.MAX_VALUE);
                ResultInterface result = c.executeQuery(0, false);
                result.next();
                String s = result.currentRow()[0].getString();
                result.close();
                hasSynonyms = "1.4.196".equals(s);
            }
        } else {
            hasSynonyms = true;
        }
        this.hasSynonyms = hasSynonyms;
    }
    return hasSynonyms;
}
Also used : SessionRemote(org.h2.engine.SessionRemote) ResultInterface(org.h2.result.ResultInterface) SessionInterface(org.h2.engine.SessionInterface) CommandInterface(org.h2.command.CommandInterface)

Example 15 with ResultInterface

use of org.h2.result.ResultInterface in project h2database by h2database.

the class ViewIndex method find.

private Cursor find(Session session, SearchRow first, SearchRow last, SearchRow intersection) {
    if (recursive) {
        return findRecursive(first, last);
    }
    setupQueryParameters(session, first, last, intersection);
    ResultInterface result = query.query(0);
    return new ViewCursor(this, result, first, last);
}
Also used : ResultInterface(org.h2.result.ResultInterface)

Aggregations

ResultInterface (org.h2.result.ResultInterface)34 Value (org.h2.value.Value)15 DbException (org.h2.message.DbException)11 LocalResult (org.h2.result.LocalResult)9 SQLException (java.sql.SQLException)8 CommandInterface (org.h2.command.CommandInterface)7 Expression (org.h2.expression.Expression)5 Column (org.h2.table.Column)5 SQLClientInfoException (java.sql.SQLClientInfoException)4 Prepared (org.h2.command.Prepared)4 Database (org.h2.engine.Database)4 ResultWithGeneratedKeys (org.h2.result.ResultWithGeneratedKeys)4 Row (org.h2.result.Row)4 IOException (java.io.IOException)3 ValueString (org.h2.value.ValueString)3 Savepoint (java.sql.Savepoint)2 GeneratedKeys (org.h2.engine.GeneratedKeys)2 ExpressionColumn (org.h2.expression.ExpressionColumn)2 SequenceValue (org.h2.expression.SequenceValue)2 ResultRemote (org.h2.result.ResultRemote)2