The problem is that INTERVAL '0 00:01:30.0' DAY TO SECOND(1)
is a literal of datatype INTERVAL
. So you cannot use a positional parameter inside it.
You have to use one of the convertion functions NUMTOYMINTERVAL
or NUMTODSINTERVAL
.
The amended SQL for the prepared statement would be
SELECT col FROM table WHERE
last_updated > SYS_EXTRACT_UTC(systimestamp) - NUMTODSINTERVAL(?,'SECOND')
and the parameter needs to be set as
stmt.setInt(1, 90);
edit As Alex mentioned himself. Another way
SELECT col FROM table WHERE
last_updated > SYS_EXTRACT_UTC(systimestamp) - TO_DSINTERVAL(?)
and the parameter can be set as string
stmt.setString("0 00:01:30.0");
A manual check that it's the same interval
select NUMTODSINTERVAL(90,'SECOND') as "NUMTODSINTERVAL",
INTERVAL '0 00:01:30.0' DAY TO SECOND(1) as "INTERVAL",
TO_DSINTERVAL('0 00:01:30.0') as "TO_DSINTERVAL"
from dual
output
NUMTODSINTERVAL INTERVAL TO_DSINTERVAL
------------------- ------------------- -------------------
+00 00:01:30.000000 +00 00:01:30.000000 +00 00:01:30.000000