I have an update SQL such like ‘UPDATE T SET d=d*2’, then query the updated value such like ‘SELECT d FROM T’. Is it possible to use one SQL call to implement this in JDBC? Thanks!
I have an update SQL such like ‘ UPDATE T SET d=d*2 ’, then
Share
No, mixing DML with SELECT queries is already not possible in plain SQL, so JDBC can’t do any much for you. You need to fire at least two queries, if necessary in a single transaction. An alternative is a stored procedure which you can then exeucte by a single
CallableStatement, but that’s overcomplicated for this particular simple purpose.