OraOpenSource / oos-utils

Common PL/SQL utility scripts
MIT License
203 stars 73 forks source link

Assert function example is wrong #202

Closed DominiqueComte closed 4 years ago

DominiqueComte commented 4 years ago

Hi,

The example output of the ASSERT function is wrong, it's a compilation error, not the function's output.

martindsouza commented 4 years ago

@dc55028 I think it is correct. Assert is a procedure. If the test (p_condition) passes nothing really "happens" (i.e. the rest of the calling method will run as expected). If the test fails, then an error is raised.

The goal of assert is to reduce the if <check> then raise_application_error(-20001, '...'); end if; calls throughout the code.

jeffreykemp commented 4 years ago

On this one I'd have to agree with the OP. The example in the docs is misleading - one would not expect a call to assert to result in a compilation error.

Error starting at line : 1 in command -
exec oos_util.assert(1=2, 'this assertion did not pass')
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'ASSERT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
DominiqueComte commented 4 years ago

the real output (on a 12.1 db at least) is this: begin oos_util.assert(1=2, 'this assertion did not pass'); end; Error report - ORA-20000: this assertion did not pass ORA-06512: at "ADMIN.OOS_UTIL", line 70 ORA-06512: at line 2

  1. 00000 - "%s" Cause: The stored procedure 'raise_application_error' was called which causes this error to be generated. Action: Correct the problem as described in the error message or contact the application administrator or DBA for more information.
martindsouza commented 4 years ago

That's my bad (misread initial ticket). Fixed the documentation and the update will be in next release. Preview here: https://github.com/OraOpenSource/oos-utils/blob/1.1.0/docs/oos_util.md#assert