-1

I'm using Jenkins for CI/CD Oracle PL/SQL scripts using Oracle SQLcl, so i want to catch syntax errors for Jenkins Pipeline, for example:

SQL> seelect * from emp;

Error que empieza en la línea: 1 del comando :
seelect * from emp
Informe de error -
Comando desconocido

How can I end connection to database with a sh/bash error code when a syntax error is detected?

NOTE: I use WHENEVER SQLERROR EXIT FAILURE to ORA-XXX errors, but i can't catch syntax errors.

Thank You

kfinity
  • 8,581
  • 1
  • 13
  • 20
  • Syntax errors are basically the interpreter *I give up, I do not know what you want*. You cannot catch them because the interpreter does not know to do so. In case it is simple: you misspelled **Select**, just 1 *E*. – Belayer Dec 02 '21 at 17:10
  • So if I have a huge PL / SQL script and it has a syntax error, is there no way to make the connection terminate with an error code? Or just the database doesn't run the script? – Salvador Arreola Rojas Dec 02 '21 at 17:29

1 Answers1

0

Ive used this before in a jenkins pipe:

 stage('Check Logs') {
    steps {
      script {
        if (manager.logContains('.*ORA-.*')) {
          error("Build failed due to ORA Errors")
        }
      }

    }
  }
  • Unfortunately, as OP mentions, syntax errors don't have an ORA- number with them. – kfinity Dec 02 '21 at 18:24
  • then look for the syntax of a syntax error the point of the code block isnt that its only looking for ORA but it can be used to look for any string pattern and fail the pipe. – Jetter McTedder Dec 03 '21 at 19:02