Search in sources :

Example 1 with SQLCastExpr

use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.

the class ItemDecimalTypecast method toExpression.

@Override
public SQLExpr toExpression() {
    SQLCastExpr cast = new SQLCastExpr();
    cast.setExpr(args.get(0).toExpression());
    SQLDataTypeImpl dataType = new SQLDataTypeImpl("DECIMAL");
    if (precision >= 0) {
        dataType.addArgument(new SQLIntegerExpr(precision));
    }
    if (dec > 0) {
        dataType.addArgument(new SQLIntegerExpr(dec));
    }
    cast.setDataType(dataType);
    return cast;
}
Also used : SQLCastExpr(com.alibaba.druid.sql.ast.expr.SQLCastExpr) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr) SQLDataTypeImpl(com.alibaba.druid.sql.ast.SQLDataTypeImpl)

Example 2 with SQLCastExpr

use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.

the class ItemFuncBinary method toExpression.

@Override
public SQLExpr toExpression() {
    SQLCastExpr cast = new SQLCastExpr();
    cast.setExpr(args.get(0).toExpression());
    SQLDataTypeImpl dataType = new SQLDataTypeImpl("BINARY");
    if (castLength >= 0) {
        dataType.addArgument(new SQLIntegerExpr(castLength));
    }
    cast.setDataType(dataType);
    return cast;
}
Also used : SQLCastExpr(com.alibaba.druid.sql.ast.expr.SQLCastExpr) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr) SQLDataTypeImpl(com.alibaba.druid.sql.ast.SQLDataTypeImpl)

Example 3 with SQLCastExpr

use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.

the class ItemNCharTypecast method toExpression.

@Override
public SQLExpr toExpression() {
    SQLCastExpr cast = new SQLCastExpr();
    cast.setExpr(args.get(0).toExpression());
    SQLDataTypeImpl dataType = new SQLDataTypeImpl("NCAHR");
    if (castLength >= 0) {
        dataType.addArgument(new SQLIntegerExpr(castLength));
    }
    cast.setDataType(dataType);
    return cast;
}
Also used : SQLCastExpr(com.alibaba.druid.sql.ast.expr.SQLCastExpr) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr) SQLDataTypeImpl(com.alibaba.druid.sql.ast.SQLDataTypeImpl)

Example 4 with SQLCastExpr

use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.

the class ItemTimeTypecast method toExpression.

@Override
public SQLExpr toExpression() {
    SQLCastExpr cast = new SQLCastExpr();
    cast.setExpr(args.get(0).toExpression());
    SQLDataTypeImpl dataType = new SQLDataTypeImpl("TIME");
    if (decimals != NOT_FIXED_DEC) {
        dataType.addArgument(new SQLIntegerExpr(decimals));
    }
    cast.setDataType(dataType);
    return cast;
}
Also used : SQLCastExpr(com.alibaba.druid.sql.ast.expr.SQLCastExpr) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr) SQLDataTypeImpl(com.alibaba.druid.sql.ast.SQLDataTypeImpl)

Example 5 with SQLCastExpr

use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.

the class ItemCharTypecast method toExpression.

@Override
public SQLExpr toExpression() {
    SQLCastExpr cast = new SQLCastExpr();
    cast.setExpr(args.get(0).toExpression());
    SQLCharacterDataType dataType = new SQLCharacterDataType(SQLCharacterDataType.CHAR_TYPE_CHAR);
    cast.setDataType(dataType);
    if (castLength >= 0) {
        dataType.addArgument(new SQLIntegerExpr(castLength));
    }
    if (charSetName != null) {
        dataType.setName(charSetName);
    }
    cast.setDataType(dataType);
    return cast;
}
Also used : SQLCastExpr(com.alibaba.druid.sql.ast.expr.SQLCastExpr) SQLCharacterDataType(com.alibaba.druid.sql.ast.statement.SQLCharacterDataType) SQLIntegerExpr(com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)

Aggregations

SQLCastExpr (com.alibaba.druid.sql.ast.expr.SQLCastExpr)10 SQLDataTypeImpl (com.alibaba.druid.sql.ast.SQLDataTypeImpl)9 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)6 SQLCharacterDataType (com.alibaba.druid.sql.ast.statement.SQLCharacterDataType)1 OracleExprParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser)1