throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 0,
"NumericExpression/IntegerLiteral/ParameterLiteral"));
}
// Create a new StringExpression and manually update its SQL
StringExpression strExpr = new StringExpression(stmt, null, null);
SQLText sql = strExpr.toSQLText();
sql.append("SUBSTRING(").append(expr).append(" FROM ").append(startExpr.add(one)).append(')');
return strExpr;
}
else
{
// {stringExpr}.substring(numExpr1, numExpr2)
SQLExpression one = ExpressionUtils.getLiteralForOne(stmt);
SQLExpression startExpr = (SQLExpression)args.get(0);
if (!(startExpr instanceof NumericExpression))
{
throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 0,
"NumericExpression"));
}
SQLExpression endExpr = (SQLExpression)args.get(1);
if (!(endExpr instanceof NumericExpression))
{
throw new NucleusException(LOCALISER.msg("060003", "substring", "StringExpression", 1,
"NumericExpression"));
}
// Create a new StringExpression and manually update its SQL
StringExpression strExpr = new StringExpression(stmt, null, null);
SQLText sql = strExpr.toSQLText();
sql.append("SUBSTRING(").append(expr).append(" FROM ").append(startExpr.add(one))
.append(" FOR ").append(endExpr.sub(startExpr)).append(')');
return strExpr;
}
}