diff --git a/.travis.yml b/.travis.yml index b9acd06..17f24f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ env: - UTPLSQL_VERSION="v3.0.4" - UTPLSQL_VERSION="v3.1.1" - UTPLSQL_VERSION="v3.1.2" + - UTPLSQL_VERSION="v3.1.3" - UTPLSQL_VERSION="develop" UTPLSQL_FILE="utPLSQL" diff --git a/src/main/java/org/utplsql/api/outputBuffer/OutputBufferProvider.java b/src/main/java/org/utplsql/api/outputBuffer/OutputBufferProvider.java index 15ba696..54a2a0b 100644 --- a/src/main/java/org/utplsql/api/outputBuffer/OutputBufferProvider.java +++ b/src/main/java/org/utplsql/api/outputBuffer/OutputBufferProvider.java @@ -1,13 +1,13 @@ package org.utplsql.api.outputBuffer; import oracle.jdbc.OracleConnection; +import oracle.jdbc.OracleTypes; import org.utplsql.api.Version; import org.utplsql.api.exception.InvalidVersionException; import org.utplsql.api.reporter.Reporter; +import java.sql.CallableStatement; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; public class OutputBufferProvider { @@ -42,26 +42,28 @@ public static OutputBuffer getCompatibleOutputBuffer(Version databaseVersion, Re private static boolean hasOutput( Reporter reporter, OracleConnection oraConn ) throws SQLException { - String sql = "select is_output_reporter " + - " from table(ut_runner.get_reporters_list)" + - " where ? = substr(reporter_object_name, length(reporter_object_name)-?+1)"; - try ( PreparedStatement stmt = oraConn.prepareStatement(sql)) { + String sql = + "declare " + + " l_result int;" + + "begin " + + " begin " + + " execute immediate '" + + " begin " + + " :x := case ' || dbms_assert.simple_sql_name( ? ) || '() is of (ut_output_reporter_base) when true then 1 else 0 end;" + + " end;'" + + " using out l_result;" + + " end;" + + " ? := l_result;" + + "end;"; + + try ( CallableStatement stmt = oraConn.prepareCall(sql)) { stmt.setQueryTimeout(3); stmt.setString(1, reporter.getTypeName()); - stmt.setInt(2, reporter.getTypeName().length()); - - try ( ResultSet rs = stmt.executeQuery() ) { - if ( rs.next() ) { - String isReporterResult = rs.getString(1); + stmt.registerOutParameter(2, OracleTypes.INTEGER); - if ( isReporterResult == null ) - throw new IllegalArgumentException("The given type " + reporter.getTypeName() + " is not a valid Reporter!"); - else - return isReporterResult.equalsIgnoreCase("Y"); - } - else - throw new SQLException("Could not check Reporter validity"); - } + stmt.execute(); + int result = stmt.getInt(2); + return result == 1; } }