Sunny
Sunny

Reputation: 47

JDBC issue when handling code in SQL file

I have an XML which is being called as part of software installer code. In the XML, I am executing SQL files using JDBC framework. The installer is failing at a point wherein the JDBC gets hole of the below statement inside a SQL file:-

Create or replace procedure test
as 
  Begin
    ...
  End;
/

show errors
/

At the occurennce of "Show Errors" , the JDBC fails and installer execution finishes.

I have tried using the below syntax, but still JDBC fails.

Begin
   show errors; 
End;
/

When I remove "Show errors" from the SQL file, the installer finishes successfully. But I need to have "Show errors" in the SQL file.

Looking for some assistance here on how to use it without JDBC failing.

Thanks.

Upvotes: 0

Views: 82

Answers (1)

user330315
user330315

Reputation:

show errors is not a SQL statement, it's a SQL*Plus command, so it only works in SQL*Plus and cannot be used through JDBC.

Under the hood show errors simply queries the view ALL_ERRORS which you can do through JDBC as well:

SELECT line, position, text
FROM all_errors 
WHERE owner = user
  AND name = 'TEST' -- replace this with the name of your procedure

Upvotes: 1

Related Questions