sql >> Base de Datos >  >> RDS >> Oracle

ORA-00604:se produjo un error en el nivel 1 de SQL recursivo

Creo que el PreparedStatement la definición debe extraerse del ciclo y reutilizarse dentro del ciclo llamando a clearParameters :

pstatement = db_connection.prepareStatement(PDSLnPConstants.UPSERT_SQL); // create a statement

for (Entry<Integer, LinkedHashMap<Integer, String>> entry : GUID_ID_MAPPING.entrySet()) {

    pstatement.setInt(1, entry.getKey());
    pstatement.setString(2, entry.getValue().get(PDSLnPConstants.CGUID_ID));
    pstatement.setString(3, entry.getValue().get(PDSLnPConstants.PGUID_ID));
    pstatement.setString(4, entry.getValue().get(PDSLnPConstants.SGUID_ID));
    pstatement.setString(5, entry.getValue().get(PDSLnPConstants.UID_ID));
    pstatement.setString(6, entry.getValue().get(PDSLnPConstants.ULOC_ID));
    pstatement.setString(7, entry.getValue().get(PDSLnPConstants.SLOC_ID));
    pstatement.setString(8, entry.getValue().get(PDSLnPConstants.PLOC_ID));
    pstatement.setString(9, entry.getValue().get(PDSLnPConstants.ALOC_ID));
    pstatement.setString(10, entry.getValue().get(PDSLnPConstants.SITE_ID));
    pstatement.executeUpdate();

    pstatement.clearParameters();

}

También puede investigar el procesamiento por lotes (addBatch ). Si está realizando pruebas, es posible que deba esperar un poco hasta que se limpien los cursores "abiertos" existentes.