Package org.hsqldb.result

Examples of org.hsqldb.result.Result


    public ClobData getClob(SessionInterface session, long position,
                            long length) {

        ResultLob resultOut = ResultLob.newLobGetRequest(id, position, length);
        Result    resultIn  = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }

        return new ClobDataID(((ResultLob) resultIn).getLobID());
    }
View Full Code Here


        return new ClobDataID(((ResultLob) resultIn).getLobID());
    }

    public void truncate(SessionInterface session, long len) {
        ResultLob resultOut = ResultLob.newLobTruncateRequest(id, len);
        Result    resultIn  = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }
    }
View Full Code Here

    public int setString(SessionInterface session, long pos, String str) {

        ResultLob resultOut = ResultLob.newLobSetCharsRequest(id, pos,
            str.toCharArray());
        Result resultIn = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }

        return str.length();
    }
View Full Code Here

            throw Error.error(ErrorCode.X_22001);
        }

        ResultLob resultOut = ResultLob.newLobSetCharsRequest(id, pos,
            str.substring(offset, len).toCharArray());
        Result resultIn = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }

        return str.length();
    }
View Full Code Here

        char[] newChars = new char[len];

        System.arraycopy(chars, offset, newChars, 0, len);

        ResultLob resultOut = ResultLob.newLobSetCharsRequest(id, pos, chars);
        Result    resultIn  = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }

        return len;
    }
View Full Code Here

    public long position(SessionInterface session, String searchstr,
                         long start) {

        ResultLob resultOut = ResultLob.newLobGetCharPatternPositionRequest(id,
            searchstr.toCharArray(), start);
        Result resultIn = session.execute(resultOut);

        if (resultIn.isError()) {
            throw resultIn.getException();
        }

        return ((ResultLob) resultIn).getOffset();
    }
View Full Code Here

        }
    }

    public Result execute(Session session) {

        Result result;

        try {
            result = getResult(session);
        } catch (Throwable t) {
            result = Result.newErrorResult(t, null);
        }

        if (result.isError()) {
            result.getException().setStatementType(group, type);

            return result;
        }

        try {
View Full Code Here

                try {
                    value = expressions[0].getValue(session);
                } catch (HsqlException e) {}

                if (value instanceof Result) {
                    Result result = (Result) value;

                    if (result.isData()) {
                        Object[] data =
                            (Object[]) result.getNavigator().getNext();
                        boolean single = !result.getNavigator().next();

                        if (single && data != null && data[0] != null) {
                            value = data[0];

                            result.getNavigator().close();
                        } else {
                            result.getNavigator().close();

                            return Result.newErrorResult(
                                Error.error(ErrorCode.X_22009), sql);
                        }
                    } else {
                        return Result.newErrorResult(
                            Error.error(ErrorCode.X_22009), sql);
                    }
                } else {
                    if (value == null) {
                        return Result.newErrorResult(
                            Error.error(ErrorCode.X_22009), sql);
                    }
                }

                long seconds = ((IntervalSecondData) value).getSeconds();

                if (-DTIType.timezoneSecondsLimit <= seconds
                        && seconds <= DTIType.timezoneSecondsLimit) {
                    session.setZoneSeconds((int) seconds);

                    return Result.updateZeroResult;
                }

                return Result.newErrorResult(Error.error(ErrorCode.X_22009),
                                             sql);
            }
            case StatementTypes.SET_NAMES :
                return Result.updateZeroResult;

            case StatementTypes.SET_PATH :
                return Result.updateZeroResult;

            case StatementTypes.SET_ROLE : {
                String  name;
                Grantee role = null;

                try {
                    name = (String) expressions[0].getValue(session);

                    if (name != null) {
                        name = (String) Type.SQL_VARCHAR.trim(session, name,
                                                              ' ', true, true);
                        role = session.database.granteeManager.getRole(name);
                    }
                } catch (HsqlException e) {
                    return Result.newErrorResult(
                        Error.error(ErrorCode.X_0P000), sql);
                }

                if (session.isInMidTransaction()) {
                    return Result.newErrorResult(
                        Error.error(ErrorCode.X_25001), sql);
                }

                if (role == null) {
                    session.setRole(null);
                }

                if (session.getGrantee().hasRole(role)) {
                    session.setRole(role);

                    return Result.updateZeroResult;
                } else {
                    return Result.newErrorResult(
                        Error.error(ErrorCode.X_0P000), sql);
                }
            }
            case StatementTypes.SET_SCHEMA : {
                String   name;
                HsqlName schema;

                try {
                    if (expressions == null) {
                        name = ((HsqlName) parameters[0]).name;
                    } else {
                        name = (String) expressions[0].getValue(session);
                    }

                    name = (String) Type.SQL_VARCHAR.trim(session, name, ' ',
                                                          true, true);
                    schema =
                        session.database.schemaManager.getSchemaHsqlName(name);

                    session.setSchema(schema.name);

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.SET_SESSION_AUTHORIZATION : {
                if (session.isInMidTransaction()) {
                    return Result.newErrorResult(
                        Error.error(ErrorCode.X_25001), sql);
                }

                try {
                    String user;
                    String password = null;

                    user = (String) expressions[0].getValue(session);
                    user = (String) Type.SQL_VARCHAR.trim(session, user, ' ',
                                                          true, true);

                    if (expressions[1] != null) {
                        password = (String) expressions[1].getValue(session);
                    }

                    User userObject;

                    if (password == null) {
                        userObject = session.database.userManager.get(user);
                    } else {
                        userObject =
                            session.database.getUserManager().getUser(user,
                                password);
                    }

                    if (userObject == null) {
                        throw Error.error(ErrorCode.X_28501);
                    }

                    sql = userObject.getConnectUserSQL();

                    if (userObject == session.getGrantee()) {
                        return Result.updateZeroResult;
                    }

                    if (session.getGrantee().canChangeAuthorisation()) {
                        session.setUser((User) userObject);
                        session.setRole(null);
                        session.resetSchema();

                        return Result.updateZeroResult;
                    }

                    /** @todo may need different error code */
                    throw Error.error(ErrorCode.X_28000);
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.SET_SESSION_CHARACTERISTICS : {
                try {
                    if (parameters[0] != null) {
                        boolean readonly =
                            ((Boolean) parameters[0]).booleanValue();

                        session.setReadOnlyDefault(readonly);
                    }

                    if (parameters[1] != null) {
                        int level = ((Integer) parameters[1]).intValue();

                        session.setIsolationDefault(level);
                    }

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.SET_COLLATION :
                return Result.updateZeroResult;

            case StatementTypes.SET_TRANSFORM_GROUP :
                return Result.updateZeroResult;

            case StatementTypes.START_TRANSACTION :
                startTransaction = true;

            // fall through
            case StatementTypes.SET_TRANSACTION : {
                try {
                    if (parameters[0] != null) {
                        boolean readonly =
                            ((Boolean) parameters[0]).booleanValue();

                        session.setReadOnly(readonly);
                    }

                    if (parameters[1] != null) {
                        int level = ((Integer) parameters[1]).intValue();

                        session.setIsolation(level);
                    }

                    if (startTransaction) {
                        session.startTransaction();
                    }

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }

            //
            case StatementTypes.SET_SESSION_AUTOCOMMIT : {
                boolean mode = ((Boolean) parameters[0]).booleanValue();

                try {
                    session.setAutoCommit(mode);

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.DECLARE_VARIABLE : {
                ColumnSchema[] variables = (ColumnSchema[]) parameters[0];

                try {
                    for (int i = 0; i < variables.length; i++) {
                        session.sessionContext.addSessionVariable(
                            variables[i]);
                    }

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.SET_SESSION_RESULT_MAX_ROWS : {
                int size = ((Integer) parameters[0]).intValue();

                session.setSQLMaxRows(size);

                return Result.updateZeroResult;
            }
            case StatementTypes.SET_SESSION_RESULT_MEMORY_ROWS : {
                int size = ((Integer) parameters[0]).intValue();

                session.setResultMemoryRowCount(size);

                return Result.updateZeroResult;
            }
            case StatementTypes.SET_SESSION_SQL_IGNORECASE : {
                try {
                    boolean mode = ((Boolean) parameters[0]).booleanValue();

                    session.setIgnoreCase(mode);

                    return Result.updateZeroResult;
                } catch (HsqlException e) {
                    return Result.newErrorResult(e, sql);
                }
            }
            case StatementTypes.DECLARE_SESSION_TABLE : {
                Table         table           = (Table) parameters[0];
                HsqlArrayList tempConstraints = (HsqlArrayList) parameters[1];
                StatementDMQL statement       = (StatementDMQL) parameters[2];

                try {
                    if (tempConstraints != null) {
                        table =
                            ParserDDL.addTableConstraintDefinitions(session,
                                table, tempConstraints, null, false);
                    }

                    table.compile(session, null);
                    session.addSessionTable(table);

                    if (statement != null) {
                        Result result = statement.execute(session);

                        table.insertIntoTable(session, result);
                    }

                    if (table.hasLobColumn) {
View Full Code Here

        checkAccessRights(session);
    }

    Result getResult(Session session) {

        Result result = queryExpression.getResult(session,
            session.getMaxRows());

        result.setStatement(this);

        return result;
    }
View Full Code Here

                    sessionMap.remove(currentId);

                    continue;
                }

                Result result = null;

                statementType = scr.getStatementType();

                switch (statementType) {

                    case ScriptReaderBase.ANY_STATEMENT :
                        statement = scr.getLoggedStatement();
                        result = current.executeDirectStatement(statement,
                                ResultProperties.defaultPropsValue);

                        if (result != null && result.isError()) {
                            if (result.getException() != null) {
                                throw result.getException();
                            }

                            throw Error.error(result);
                        }
                        break;
View Full Code Here

TOP

Related Classes of org.hsqldb.result.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.