Search in sources :

Example 66 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class DeleteExecutor method doTranslate.

@Override
protected List<Value> doTranslate(TableNode node, SearchRow row, StatementBuilder buff) {
    ArrayList<Value> params = New.arrayList();
    TableFilter tableFilter = prepared.getTableFilter();
    String forTable = node.getCompositeObjectName();
    Expression condition = prepared.getCondition();
    Expression limitExpr = prepared.getLimitExpr();
    buff.append("DELETE FROM ");
    buff.append(identifier(forTable));
    if (condition != null) {
        condition.exportParameters(tableFilter, params);
        buff.append(" WHERE ").append(StringUtils.unEnclose(condition.getSQL()));
    }
    if (limitExpr != null) {
        limitExpr.exportParameters(tableFilter, params);
        buff.append(" LIMIT ").append(StringUtils.unEnclose(limitExpr.getSQL()));
    }
    return params;
}
Also used : TableFilter(com.wplatform.ddal.dbobject.table.TableFilter) Expression(com.wplatform.ddal.command.expression.Expression) Value(com.wplatform.ddal.value.Value)

Example 67 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class JdbcConnection method createBlob.

/**
 * Create a Blob value from this input stream.
 *
 * @param x      the input stream
 * @param length the length (if smaller or equal than 0, all data until the
 *               end of file is read)
 * @return the value
 */
public Value createBlob(InputStream x, long length) {
    if (x == null) {
        return ValueNull.INSTANCE;
    }
    if (length <= 0) {
        length = -1;
    }
    Value v = ValueLobDb.createTempBlob(x, length);
    session.addTemporaryLob(v);
    return v;
}
Also used : Value(com.wplatform.ddal.value.Value)

Example 68 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class JdbcConnection method createNClob.

/**
 * Create a new empty NClob object.
 *
 * @return the object
 */
@Override
public NClob createNClob() throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()");
        checkClosedForWrite();
        try {
            Value v = ValueLobDb.createTempClob(new InputStreamReader(new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0);
            session.addTemporaryLob(v);
            return new JdbcClob(this, v, id);
        } finally {
            afterWriting();
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) Value(com.wplatform.ddal.value.Value) Savepoint(java.sql.Savepoint) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException) DbException(com.wplatform.ddal.message.DbException)

Example 69 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class JdbcConnection method createClob.

/**
 * Create a Clob value from this reader.
 *
 * @param x      the reader
 * @param length the length (if smaller or equal than 0, all data until the
 *               end of file is read)
 * @return the value
 */
public Value createClob(Reader x, long length) {
    if (x == null) {
        return ValueNull.INSTANCE;
    }
    if (length <= 0) {
        length = -1;
    }
    Value v = ValueLobDb.createTempClob(x, length);
    session.addTemporaryLob(v);
    return v;
}
Also used : Value(com.wplatform.ddal.value.Value)

Example 70 with Value

use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.

the class Session method getVariable.

/**
 * Get the value of the specified user defined variable. This method always
 * returns a value; it returns ValueNull.INSTANCE if the variable doesn't
 * exist.
 *
 * @param name the variable name
 * @return the value, or NULL
 */
public Value getVariable(String name) {
    initVariables();
    Value v = variables.get(name);
    return v == null ? ValueNull.INSTANCE : v;
}
Also used : Value(com.wplatform.ddal.value.Value)

Aggregations

Value (com.wplatform.ddal.value.Value)84 Expression (com.wplatform.ddal.command.expression.Expression)14 Column (com.wplatform.ddal.dbobject.table.Column)14 StatementBuilder (com.wplatform.ddal.util.StatementBuilder)13 DbException (com.wplatform.ddal.message.DbException)9 SQLException (java.sql.SQLException)8 Row (com.wplatform.ddal.result.Row)7 SearchRow (com.wplatform.ddal.result.SearchRow)7 PreparedStatement (java.sql.PreparedStatement)7 TableMate (com.wplatform.ddal.dbobject.table.TableMate)6 LocalResult (com.wplatform.ddal.result.LocalResult)6 ResultInterface (com.wplatform.ddal.result.ResultInterface)5 Connection (java.sql.Connection)5 Parameter (com.wplatform.ddal.command.expression.Parameter)4 List (java.util.List)4 DataSource (javax.sql.DataSource)4 Query (com.wplatform.ddal.command.dml.Query)3 TableFilter (com.wplatform.ddal.dbobject.table.TableFilter)3 TableNode (com.wplatform.ddal.dispatch.rule.TableNode)3 JdbcWorker (com.wplatform.ddal.excutor.JdbcWorker)3