Closed DominiqueComte closed 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.
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:
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
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
Hi,
The example output of the ASSERT function is wrong, it's a compilation error, not the function's output.