node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

Why does my procedure with syntax errors is executing with success ?

Open gspaiva opened this issue 8 years ago • 7 comments

I have some procedures in .sql files, I'm reading these files and executing them through execute() method, these scripts are basically ( CREATE OR REPLACE PROCEDURE). The problem is: Even when there are some syntax errors the script is executed with success, is There way to get the errors instead of success? Thanks everybody already.

gspaiva avatar Jan 05 '18 15:01 gspaiva

@gspaiva The object will still be created, just in an invalid state.

Given the following procedure:

create or replace procedure test
as

  l_number number;

begin

  select 1
  into l_number
  from table_that_does_not_exist;

end;
/

You can get the compilation errors with:

select *
from user_errors
where name = 'TEST'
  and type = 'PROCEDURE'
order by sequence;

You can check the status with:

select status
from user_objects
where object_name = 'TEST'
  and object_type = 'PROCEDURE';

dmcghan avatar Jan 05 '18 15:01 dmcghan

Thanks for aswering! Closing this issue.

gspaiva avatar Jan 05 '18 16:01 gspaiva

So this seems fine if you know the script you are running. But what if you are running n number or arbitrary statements. For example you have to compile multiple packages or procedures.

Could there be a way to force a compilation error to show up as warnings. Kind of similar to the show errors command in sqlplus? Or something like oracledb.warningsAsErrors = true.

Or even a more generic query to get the result of the last thing you ran?

bill-kitsune avatar Feb 13 '18 15:02 bill-kitsune

@bill-kitsune good question, and one on our list to look at. Our rough thoughts were to have an execute() property like the one you mention, and also a boolean flag in the Error structure to indicate whether the error was a real error or SUCCESS_WITH_INFO. Would this work?

cjbj avatar Feb 14 '18 01:02 cjbj

@cjbj It would be a great way to help us to get warning messages or even success with info messages. Already waiting for that.

gspaiva avatar Feb 14 '18 12:02 gspaiva

@cjbj yeah I think that would be great, it would certainly suite my use case pretty well. Should I make a feature request issue for this? Does one already exist?

bill-kitsune avatar Feb 14 '18 13:02 bill-kitsune

@bill-kitsune I changed this issue to an enhancement so you can track it. I already had it noted on the big todo list I keep.

cjbj avatar Feb 15 '18 00:02 cjbj

@bill-kitsune @gspaiva Good news that you have been waiting for!

We have introduced the warning property to report PL/SQL compilation failures and password being in grace period warnings in node-oracledb 6.3. Please check the PL/SQL warning and connection warning documentation for more information.

Some sample code is available in test/passwordExpiryWarning.js and test/plsqlWarnings.js. Will update the examples folder also.

sharadraju avatar Dec 21 '23 11:12 sharadraju