I'm trying to query some data from my DB, This is my SQL code and it runs smoothly in the console:
select BTN_NAME as btnName,
LAST_EXEC_TIME as lastExecTime,
LAST_EXEC_PARAM as lastExecParam
from BTN_FUNC_FLOW_CTRL
where BTN_NAME = 'REG_FILE_COLLECT' AND LAST_EXEC_TIME >= (SYSTIMESTAMP - INTERVAL '60' MINUTE);
But when I wrote this sql in mybatis and executed it, something went wrong, I got an ORA-00907
<select id="getByBtnName" resultType="xxx.BtnFuncFlowCtrl">
select BTN_NAME as btnName,
LAST_EXEC_TIME as lastExecTime,
LAST_EXEC_PARAM as lastExecParam
from regulatory.BTN_FUNC_FLOW_CTRL
where BTN_NAME = #{btnName} and LAST_EXEC_TIME >= (SYSTIMESTAMP - INTERVAL #{execInterval} MINUTE);
</select>
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
### The error may exist in file [C:\Users\Administrator\IdeaProjects\xxx\BtnFuncFlowCtrlMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select BTN_NAME as btnName, LAST_EXEC_TIME as lastExecTime, LAST_EXEC_PARAM as lastExecParam from regulatory.BTN_FUNC_FLOW_CTRL where BTN_NAME = ? and LAST_EXEC_TIME >= (SYSTIMESTAMP - INTERVAL ? MINUTE);
### Cause: java.sql.SQLSyntaxErrorException: ORA-00907:missing right parenthesis
When I remove the parenthesis, I got an ORA-00933
<select id="getByBtnName" resultType="xxx.BtnFuncFlowCtrl">
select BTN_NAME as btnName,
LAST_EXEC_TIME as lastExecTime,
LAST_EXEC_PARAM as lastExecParam
from regulatory.BTN_FUNC_FLOW_CTRL
where BTN_NAME = #{btnName} and LAST_EXEC_TIME >= SYSTIMESTAMP - INTERVAL #{execInterval} MINUTE;
</select>
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
### The error may exist in file [C:\Users\Administrator\IdeaProjects\xxx\BtnFuncFlowCtrlMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select BTN_NAME as btnName, LAST_EXEC_TIME as lastExecTime, LAST_EXEC_PARAM as lastExecParam from regulatory.BTN_FUNC_FLOW_CTRL where BTN_NAME = ? and LAST_EXEC_TIME >= SYSTIMESTAMP - INTERVAL ? MINUTE;
### Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
I wonder why those questions arise and how to fix them.