Package org.eigenbase.sql.util

Examples of org.eigenbase.sql.util.SqlBuilder


    public void create(
        FemUser user,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "USER", stmt);

        name(sb, null, user.getName());
        stmt.addStmt(sb.getSqlAndClear());

        sb.append(NL);
        if (user.getEncryptedPassword() == null) {
            sb.append("AUTHORIZATION ");
            // Auths are not stored by the parser.
            sb.literal("Unused");
        } else {
            sb.append("IDENTIFIED BY ");
            sb.literal("********");
        }
        stmt.addStmt(sb.getSqlAndClear());

        CwmNamespace ns = user.getDefaultNamespace();
        if (ns != null) {
            sb.append(NL);
            sb.append("DEFAULT ");
            if (ns instanceof FemLocalSchema) {
                sb.append("SCHEMA ");
            } else if (ns instanceof FemLocalCatalog) {
                sb.append("CATALOG ");
            }
            name(sb, ns.getNamespace(), ns.getName());
        }
        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here


    public void create(
        FemRole role,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "ROLE", stmt);

        name(sb, null, role.getName());

        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

    public void create(
        FemJar jar,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "JAR", stmt);

        name(sb, jar.getNamespace(), jar.getName());
        addDescription(sb, jar);

        stmt.addStmt(sb.getSqlAndClear());
        sb.append(NL);
        sb.append("LIBRARY ");
        sb.literal(jar.getUrl());
        sb.append(NL);
        sb.append("OPTIONS(");
        sb.append(jar.getDeploymentState());
        sb.append(")");

        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

    public void create(
        FemLocalTable table,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "TABLE", false, null);

        name(sb, table.getNamespace(), table.getName());
        stmt.addStmt(sb.getSqlAndClear());

        addColumns(sb, table);
        addOptions(
            sb,
            table.getStorageOptions());
        addDescription(sb, table);
        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

    public void create(
        FemForeignTable table,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "FOREIGN TABLE", false, null);

        name(sb, table.getNamespace(), table.getName());
        stmt.addStmt(sb.getSqlAndClear());

        addColumns(sb, table);
        sb.append(NL);
        sb.append("SERVER ");
        FemDataServer server = table.getServer();
        if (server != null) {
            name(sb, null, server.getName());
        }
        addOptions(
            sb,
            ((FemElementWithStorageOptions) table).getStorageOptions());
        addDescription(sb, table);
        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

    public void create(
        FemDataWrapper wrapper,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        createHeader(sb, "FOREIGN DATA WRAPPER", stmt);

        name(sb, null, wrapper.getName());
        stmt.addStmt(sb.getSqlAndClear());

        // "LIBRARY" clause is optional
        if (wrapper.getLibraryFile() != null) {
            sb.append(" LIBRARY ");
            sb.literal(wrapper.getLibraryFile());
        }
        sb.append(NL);
        sb.append("LANGUAGE ");
        sb.append(wrapper.getLanguage());
        addOptions(
            sb,
            wrapper.getStorageOptions());
        addDescription(sb, wrapper);
        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

    public void create(
        FemRoutine routine,
        GeneratedDdlStmt stmt)
    {
        SqlBuilder sb = createSqlBuilder();
        final ProcedureType routineType = routine.getType();
        final CwmClassifier owner = routine.getSpecification().getOwner();
        boolean method =
            (routine.getSpecification() != null)
            && (owner
                instanceof FemUserDefinedType);
        if (method) {
            createHeader(sb, "SPECIFIC METHOD", stmt);
        } else if (routineType.equals(ProcedureTypeEnum.FUNCTION)) {
            createHeader(sb, "FUNCTION", stmt);
        } else if (routineType.equals(ProcedureTypeEnum.PROCEDURE)) {
            createHeader(sb, "PROCEDURE", stmt);
        }

        name(sb, routine.getNamespace(), routine.getInvocationName());
        stmt.addStmt(sb.getSqlAndClear());

        if (method) {
            sb.append(NL);
            sb.append("FOR ");
            name(sb, owner.getNamespace(), owner.getName());
        } else {
            methodBody(routine, sb);
        }

        if (routine.getExternalName() == null) {
            sb.append(NL);
            sb.append(routine.getBody().getBody());
        }

        stmt.addStmt(sb.getSqlAndClear());
    }
View Full Code Here

        if ((schemaName != null)
            && (evenIfUnchanged
                || (previousSetSchema == null)
                || !previousSetSchema.equals(schemaName)))
        {
            SqlBuilder sb = createSqlBuilder();
            sb.append("SET SCHEMA ");
            sb.literal(sb.getDialect().quoteIdentifier(schemaName));
            stmt.addStmt(sb.getSql());
            previousSetSchema = schemaName;
            return true;
        } else {
            return false;
        }
View Full Code Here

        }
    }

    protected SqlBuilder createSqlBuilder()
    {
        return new SqlBuilder(sqlDialect);
    }
View Full Code Here

        throws SQLException
    {
        String initialSchema = info.getProperty("schema");
        if (initialSchema != null) {
            Statement stmt = this.createStatement();
            final SqlBuilder buf = new SqlBuilder(SqlDialect.EIGENBASE);
            buf.append("set schema ");
            buf.literal(initialSchema);
            final String sql = buf.getSql();
            try {
                stmt.executeUpdate(sql);
            } finally {
                try {
                    stmt.close();
View Full Code Here

TOP

Related Classes of org.eigenbase.sql.util.SqlBuilder

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.