[ 
https://issues.apache.org/jira/browse/GROOVY-7256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14949165#comment-14949165
 ] 

Alan Hengle commented on GROOVY-7256:
-------------------------------------

I'll go ahead and close it, since I don't think it would be (and I think should 
not be) up to groovy to issue an additional query after every statement just to 
see if there were errors.  Definitely a responsibility left to the user.  I was 
not aware SqlDeveloper was doing this, but that certainly explains the 
discrepancy.

Thanks for checking into this!

> Sql.execute() does not report errors in "create function" 
> ----------------------------------------------------------
>
>                 Key: GROOVY-7256
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7256
>             Project: Groovy
>          Issue Type: Bug
>          Components: SQL processing
>    Affects Versions: 2.3.9
>         Environment: xubuntu linux, release 14.04 (trusty), kernel 3.13.0-40
> oracle (ojdbc6.jar) release 11g version 2
> java 1.8
>            Reporter: Alan Hengle
>              Labels: database, oracle
>
> 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:
> {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()
> {code}
> 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



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to