-
1. Re: how to change the value of a where clause exprssion in createResultSetExecution
shawkins Oct 30, 2017 8:46 AM (in response to mkamran)Your logic to do this will depend upon a few factors, such as what types of commands you can handle (just Select or also SetQuery), what predicates are allowed, etc. Navigating directly looks like:
Select select = (Select)command;
Condition condition = select.getWhere();
if (condition instanceof Comparison) {
Comparison comparison = (Comparison)condition;
Expression lex = comparison.getLeftExpression();
if (lex instanceof ColumnReference) {
//further test that it's the column reference you want
//set the right to a new literal
comparison.setRightExpression(new Literal("new value", String.class));
}
}
You may also use a visitor:
HierarchyVisitor visitor = new HierarchyVisitor() {
public void visit(Comparison obj) {
//do something here
}
};
Select select = (Select)command;
Condition condition = select.getWhere();
if (condition != null) {
condition.acceptVisitor(visitor);
}
Finally you may also want to consider if there is a way to do this type of manipulation using a standard mechanism, such as row level data role conditions.