When running this query SELECT SYSDATE + INTERVAL '7' DAY FROM DUAL;
in a prepareStatement
like this
PreparedStatement ps = connection.prepareStatement("select sysdate + interval ? day from dual" );
ps.setString(1, "7");
ps.executeQuery();
It will throw an exception, that the syntax is not good, it clearly is, cuz i'm able to run the same query in sql-developer.
Is this a bug in PreparedStatement
? can i use prepared statements together with interval?
Restriction: For a PreparedStatement that contains an IN predicate, the expression that is the argument of the IN predicate cannot have more than 32767 parameters if the target data server is a Db2® on Linux®, UNIX, and Windows systems system. Otherwise, the IBM Data Server Driver for JDBC and SQLJ throws an SQLException with error code -4499.
Now close the settings window and click on ‘ Develop ‘ in the title menu at the top of your screen. You will now be shown a sub-menu. Scroll down and click on ‘ Empty Caches ‘. This will clear all the cache files from Safari which should solve the ‘ Error performing query ‘ issue for you.
This is where Keep errors can be helpful. To keep rows that have errors, first select the column that contains errors. On the Home tab, in the Reduce rows group, select Keep rows. From the drop-down menu, select Keep errors.
In case you are still facing the ‘Error performing query’ issue despite trying the fixes above, we recommend you to uninstall and reinstall the app on your device. A fresh installation can fix overlapping codes and conflicts with other services in the background which should help solve the ‘Error performing query’ issue for you.
The entire expression INTERVAL '7' DAY
is a literal, you cannot simply replace a part of it with a variable (parameter). Use the function NUMTODSINTERVAL(?,'DAY')
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With