Examples of DBRowSet


Examples of org.apache.empire.db.DBRowSet

    {
        resetParamUsage();
        if (set == null)
            return null;
        StringBuilder buf = new StringBuilder("UPDATE ");
        DBRowSet table =  set.get(0).getTable();
        long context = CTX_FULLNAME;
        // Optimizer Hint
        if (StringUtils.isNotEmpty(optimizerHint))
        {   // Append an optimizer hint to the select statement e.g. SELECT /*+ RULE */
            buf.append("/*+ ").append(optimizerHint).append(" */ ");
            // Append alias (if necessary)
            if (optimizerHint.contains(table.getAlias()))
                context |= CTX_ALIAS;
        }
        // table
        table.addSQL(buf, context);
        // Simple Statement
        context = CTX_NAME | CTX_VALUE;
        // Set Expressions
        buf.append("\r\nSET ");
        addListExpr(buf, set, context, ", ");
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    protected String getUpdateWithJoins()
    {
        // Generate Merge expression
        resetParamUsage();
        StringBuilder buf = new StringBuilder("MERGE INTO ");
        DBRowSet table =  set.get(0).getTable();
        table.addSQL(buf, CTX_FULLNAME|CTX_ALIAS);
        // join (only one allowed yet)
        DBJoinExpr updateJoin = null;
        for (DBJoinExpr jex : joins)
        {   // The join
            if (jex.isJoinOn(table)==false)
                continue;
            // found the join
            updateJoin = jex;
            break;
        }
        if (updateJoin==null)
            throw new ObjectNotValidException(this);
        Set<DBColumn> joinColumns = new HashSet<DBColumn>();
        updateJoin.addReferencedColumns(joinColumns);
        // using
        buf.append("\r\nUSING ");
        DBCommand inner = this.clone();
        inner.clearSelect();
        inner.clearOrderBy();
        for (DBColumn jcol : joinColumns)
        {   // Select join columns
            if (jcol.getRowSet()!=table)
                inner.select(jcol);
        }
        for (DBSetExpr sex : set)
        {   // Select set expressions
            Object val = sex.getValue();
            if (val instanceof DBColumnExpr)
                inner.select(((DBColumnExpr)val));
        }
        // remove join (if not necessary)
        if (inner.hasConstraintOn(table)==false)
            inner.removeJoinsOn(table);
        // add SQL for inner statement
        inner.addSQL(buf, CTX_DEFAULT);
        // find the source table
        DBColumnExpr left  = updateJoin.getLeft();
        DBColumnExpr right = updateJoin.getRight();
        DBRowSet source = right.getUpdateColumn().getRowSet();
        if (source==table)
            source = left.getUpdateColumn().getRowSet();
        // add Alias
        buf.append(" ");
        buf.append(source.getAlias());
        buf.append("\r\nON (");
        left.addSQL(buf, CTX_DEFAULT);
        buf.append(" = ");
        right.addSQL(buf, CTX_DEFAULT);
        // Compare Expression
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

            }
            int co = name.lastIndexOf('.');
            int to = name.lastIndexOf('.', co - 1);
            String cn = name.substring(co + 1);
            String tn = name.substring(to + 1, co);
            DBRowSet rs = db.getRowSet(tn);
            if (rs == null)
            {
                log.error("Table/View '{}' not found in database!", tn);
                return null; // not found
            }
            Column column = rs.getColumn(cn);
            if (column == null)
            {
                log.error("Column '{}' not found in table/view '{}'!", cn, tn);
                return null; // not found
            }
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

            return column;
        }
        else if (base instanceof DBDatabase)
        {   // Lookup RowSet
            String   name = StringUtils.toString(property);
            DBRowSet rset = ((DBDatabase)base).getRowSet(name);
            if (rset!=null)
                context.setPropertyResolved(true);
            else
                log.error("ELResolver error: Table/View '{}' cannot be resolved.", name.toUpperCase());
            // done
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    {
        if (rowset==null)
            return false;
        DBColumn l = (left !=null ? left .getUpdateColumn() : null);
        DBColumn r = (right!=null ? right.getUpdateColumn() : null);
        DBRowSet rsl = (l!=null ? l.getRowSet() : null);
        DBRowSet rsr = (r!=null ? r.getRowSet() : null);
        return rowset.equals(rsl) || rowset.equals(rsr);
    }
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    {
        if (rowset==null)
            return false;
        DBColumn l = (left !=null ? left .getUpdateColumn() : null);
        DBColumn r = (right!=null ? right.getUpdateColumn() : null);
        DBRowSet rsl = (l!=null ? l.getRowSet() : null);
        DBRowSet rsr = (r!=null ? r.getRowSet() : null);
        return rowset.equals(rsl) || rowset.equals(rsr);
    }
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    {
        resetParamUsage();
        if (set == null)
            return null;
        StringBuilder buf = new StringBuilder("UPDATE ");
        DBRowSet table =  set.get(0).getTable();
        long context = CTX_FULLNAME;
        // Optimizer Hint
        if (StringUtils.isNotEmpty(optimizerHint))
        {   // Append an optimizer hint to the select statement e.g. SELECT /*+ RULE */
            buf.append("/*+ ").append(optimizerHint).append(" */ ");
            // Append alias (if necessary)
            if (optimizerHint.contains(table.getAlias()))
                context |= CTX_ALIAS;
        }
        // table
        table.addSQL(buf, context);
        // Simple Statement
        context = CTX_NAME | CTX_VALUE;
        // Set Expressions
        buf.append("\r\nSET ");
        addListExpr(buf, set, context, ", ");
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    protected String getUpdateWithJoins()
    {
        // Generate Merge expression
        resetParamUsage();
        StringBuilder buf = new StringBuilder("MERGE INTO ");
        DBRowSet table =  set.get(0).getTable();
        table.addSQL(buf, CTX_FULLNAME|CTX_ALIAS);
        // join (only one allowed yet)
        DBJoinExpr updateJoin = null;
        for (DBJoinExpr jex : joins)
        {   // The join
            if (jex.isJoinOn(table)==false)
                continue;
            // found the join
            updateJoin = jex;
            break;
        }
        if (updateJoin==null)
            throw new ObjectNotValidException(this);
        Set<DBColumn> joinColumns = new HashSet<DBColumn>();
        updateJoin.addReferencedColumns(joinColumns);
        // using
        buf.append("\r\nUSING ");
        DBCommand inner = this.clone();
        inner.clearSelect();
        inner.clearOrderBy();
        for (DBColumn jcol : joinColumns)
        {   // Select join columns
            if (jcol.getRowSet()!=table)
                inner.select(jcol);
        }
        for (DBSetExpr sex : set)
        {   // Select set expressions
            Object val = sex.getValue();
            if (val instanceof DBColumnExpr)
                inner.select(((DBColumnExpr)val));
        }
        inner.removeJoinsOn(table);
        inner.addSQL(buf, CTX_DEFAULT);
        // find the source table
        DBColumnExpr left  = updateJoin.getLeft();
        DBColumnExpr right = updateJoin.getRight();
        DBRowSet source = right.getUpdateColumn().getRowSet();
        if (source==table)
            source = left.getUpdateColumn().getRowSet();
        // add Alias
        buf.append(" ");
        buf.append(source.getAlias());
        buf.append("\r\nON (");
        left.addSQL(buf, CTX_DEFAULT);
        buf.append(" = ");
        right.addSQL(buf, CTX_DEFAULT);
        // Compare Expression
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

    {
        if (rowset==null)
            return false;
        DBColumn l = (left !=null ? left .getUpdateColumn() : null);
        DBColumn r = (right!=null ? right.getUpdateColumn() : null);
        DBRowSet rsl = (l!=null ? l.getRowSet() : null);
        DBRowSet rsr = (r!=null ? r.getRowSet() : null);
        return rowset.equals(rsl) || rowset.equals(rsr);
    }
View Full Code Here

Examples of org.apache.empire.db.DBRowSet

            }
            int co = name.lastIndexOf('.');
            int to = name.lastIndexOf('.', co - 1);
            String cn = name.substring(co + 1);
            String tn = name.substring(to + 1, co);
            DBRowSet rs = db.getRowSet(tn);
            if (rs == null)
            {
                log.error("Table/View '{}' not found in database!", tn);
                return null; // not found
            }
            Column column = rs.getColumn(cn);
            if (column == null)
            {
                log.error("Column '{}' not found in table/view '{}'!", cn, tn);
                return null; // not found
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.