When I use the following query, it works.
query = "INSERT INTO MLRL1_PSR_MASTER (PROJECT_ID,FROM_DATE,TO_DATE,TEMPLATE_ID,TEMPLATE_TYPE,UPLOADED_BY,PSR_SLABID) " + " select '"+projectId+"' , FROM_DATE , TO_DATE,'"+templateId+"','"+tempType+"','"+user.getUserID()+"', "+slabId+ " from MLRL1_PSR_SLABS where SLAB_ID="+slabId+" "; stmt = connection.prepareStatement(query, new String[] { "ID" }); stmt.executeUpdate(); stmt = connection.prepareStatement(query);
but if I use the same query with getGeneratedKeys (), like:
stmt = connection.prepareStatement(query, new String[] { "ID" }); stmt.executeUpdate(); ResultSet rs = stmt.getGeneratedKeys(); while (rs.next()) { masterId = rs.getInt(1); }
I get an error
ORA-00933: SQL command not executed properly
stmt is java.sql.PreparedStatement , code matching is 1.6, and JRE is 1.7.67. The Oracle Driver is odbc6, and the database is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
source share