I want to add new condition to my sql. For example If query is;
SELECT EMP_ID, FIRST_NAME FROM EMPLOYEES;
I can add new where cause with this codes;
@Override
protected void setLimit(final PlainSelect ps,final long rowLimit) {
Expression where = ps.getWhere();
if(where == null) {
try {
where = CCJSqlParserUtil.parseCondExpression("ROWNUM < " + (rowLimit+1) );
} catch (JSQLParserException e) {
e.printStackTrace();
}
}
ps.setWhere(where);
}
This codes changes the query to
SELECT EMP_ID, FIRST_NAME FROM EMPLOYEES WHERE ROWNUM < 10;
...
But the problem is when query is like;
SELECT EMP_ID, FIRST_NAME FROM EMPLOYEES WHERE EMP_ID = 10 AND EMP_ID = 10 AND FIRST_NAME = 'Steven';
I cannot add new condition to current condition. Is there a way to change this query to like;
SELECT EMP_ID, FIRST_NAME FROM EMPLOYEES WHERE EMP_ID = 10 AND EMP_ID = 10 AND FIRST_NAME = 'Steven' AND ROWNUM < 10;
Is there a way to do that with JSqlParser?