Robotic Process Automation (RPA)

 View Only
Expand all | Collapse all

Execute "Run SQL Command" on Oracle Database

  • 1.  Execute "Run SQL Command" on Oracle Database

    Posted Wed May 31, 2023 10:16 AM

    Hello Guys ,

    I'm trying to execute some INSERT and UPDATE querys on a Oracle Database using the "Run SQL Command but the command it is not working.
    I'm trying to execute this query:

    UPDATE CAT_NODOSP_HISTORICO H
    SET H.FEC_FIN=(SELECT N.FEC_FIN FROM CAT_NODOS N
    WHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND
    N.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED)
    WHERE EXISTS (SELECT 1 FROM CAT_NODOS N
    WHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND
    N.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED)

    RPA command code:
    sqlExecute --connection ${dbConnection} --statement "UPDATE CAT_NODOSP_HISTORICO H\r\nSET H.FEC_FIN=(SELECT N.FEC_FIN FROM CAT_NODOS N\r\nWHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND\r\nN.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED)\r\nWHERE EXISTS (SELECT 1 FROM CAT_NODOS N\r\nWHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND\r\nN.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED);" vResultadoEjecucion=value
      

    and I get this error:
    5/28/2023 6:59:11 PM - Error executing command at line 364: sqlExecute --connection ${dbConnection} --statement "UPDATE CAT_NODOSP_HISTORICO H\r\nSET H.FEC_FIN=(SELECT N.FEC_FIN FROM CAT_NODOS N\r\nWHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND\r\nN.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED)\r\nWHERE EXISTS (SELECT 1 FROM CAT_NODOS N\r\nWHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND\r\nN.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED);" vResultadoEjecucion=value
        Error executing: UPDATE CAT_NODOSP_HISTORICO H
    SET H.FEC_FIN=(SELECT N.FEC_FIN FROM CAT_NODOS N
    WHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND
    N.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED)
    WHERE EXISTS (SELECT 1 FROM CAT_NODOS N
    WHERE N.SISTEMA=H.SISTEMA AND N.GCR=H.GCR AND N.ZONA_CARGA=H.ZONA_CARGA AND
    N.CLAVE_NODOP=H.CLAVE_NODOP AND N.TENSION=H.TENSION AND N.ENT_FED=H.ENT_FED);

    There is not much explanation on the error message, so I hope you can help me . What is missing  in order to make the command works ?

    Thanks in advanced.



    ------------------------------
    JORGE RAMSES ZARATE CARREOLA
    ------------------------------


  • 2.  RE: Execute "Run SQL Command" on Oracle Database

    Posted Thu June 01, 2023 02:03 PM

    I solved this issue! 

    If you do some UPDATE or INSERT on the database you need to execute a "COMMIT" before any other change, so I just add a "commit" and it works



    ------------------------------
    JORGE RAMSES ZARATE CARREOLA
    ------------------------------