Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7256

Sql.execute() does not report errors in "create function"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.3.9
    • Fix Version/s: None
    • Component/s: SQL processing
    • Labels:
    • Environment:
      xubuntu linux, release 14.04 (trusty), kernel 3.13.0-40
      oracle (ojdbc6.jar) release 11g version 2
      java 1.8

      Description

      Attempt to create a function that contains a compile error using Sql.execute() and the error is not reported (i.e. no exception is thrown). When running the same "create" in SqlDeveloper connected to the same database, errors are shown.

      Sample code:

      import groovy.sql.Sql
      
      def driver = 'oracle.jdbc.pool.OracleDataSource'
      def url = ['jdbc:oracle:thin:@<ip_addr>:1521:<sid>', '<username>', '<pw>']
      def sql = Sql.newInstance(*url, driver)
      try {
      	sql.execute('drop function badfunc')
      } catch(Exception s) {
          println s.getMessage()
      }
      try {
        sql.execute('''
          CREATE OR REPLACE FUNCTION badfunc RETURN NUMBER IS
      BEGIN
       RETURN whathaveyou;
      END;
      ''')
      } catch(Throwable t) {
      	println t.getMessage()
      }
      println "create finished"
      sql.close()
      

      result:
      (shows error on "drop" the first time)
      create finished
      (the function exists afterward with an "INVALID" status)

      result from SqlDeveloper:
      Error(5,9): PLS-00201: identifier 'WHATHAVEYOU' must be declared

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              reddierocket Alan Hengle
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: