1

Topic: BOOLEAN NOT NULL

There is a code

CREATE OR REPLACE PACKAGE PKG IS
SUBTYPE BOOLEAN_NOT_NULL IS BOOLEAN NOT NULL;
PROCEDURE ASSERT (CONDITION_IN IN BOOLEAN);
PROCEDURE ASSERT_NN (CONDITION_IN IN PKG.BOOLEAN_NOT_NULL);
END PKG;
CREATE OR REPLACE PACKAGE BODY PKG IS
PROCEDURE ASSERT (CONDITION_IN IN BOOLEAN) IS
BEGIN
IF CONDITION_IN THEN
RETURN;
ELSIF NOT CONDITION_IN THEN
RAISE_APPLICATION_ERROR (-20001, ' FAILED ');
ELSE
RAISE_APPLICATION_ERROR (-20002, ' UNKNOWN ');
END IF;
END ASSERT;
PROCEDURE ASSERT_NN (CONDITION_IN IN PKG.BOOLEAN_NOT_NULL) IS
BEGIN
IF CONDITION_IN THEN
RETURN;
ELSIF NOT CONDITION_IN THEN
RAISE_APPLICATION_ERROR (-20001, ' FAILED ');
ELSE
RAISE_APPLICATION_ERROR (-20002, ' UNKNOWN ');
END IF;
END ASSERT_NN;
END PKG;

We launch tests

EXEC PKG.ASSERT (1=1);
EXEC PKG.ASSERT (1=2);
EXEC PKG.ASSERT (NULL IS NULL);
EXEC PKG.ASSERT (NULL=1);
EXEC PKG.ASSERT (NULL);
EXEC PKG.ASSERT_NN (1=1);
EXEC PKG.ASSERT_NN (1=2);
EXEC PKG.ASSERT_NN (NULL IS NULL);
EXEC PKG.ASSERT_NN (NULL=1);
EXEC PKG.ASSERT_NN (NULL);

Results

PL/SQL procedure successfully completed.
ORA-20001: FAILED
PL/SQL procedure successfully completed.
ORA-20002: UNKNOWN
ORA-20002: UNKNOWN
PL/SQL procedure successfully completed.
ORA-20001: FAILED
PL/SQL procedure successfully completed.
ORA-06502: PL/SQL: numeric or value error
PLS-00567: cannot pass NULL to a NOT NULL constrained formal parameter

Instead of ORA-06502 it was expected UNKNOWN.
Or it is logical??
By the way, the last two errors arise even if a body the invalid.
For example, if to add "PROCEDURE FAKE;" in I will bake and to compile.

2

Re: BOOLEAN NOT NULL

BOOLEAN NOT NULL wrote:

Instead of ORA-06502 it was expected UNKNOWN.
Or it is logical??

And for what you then declared NOT NULL-nost?

BOOLEAN NOT NULL wrote:

By the way, the last two errors arise even if a body the invalid.

the Optimizing compiler.

3

Re: BOOLEAN NOT NULL

Elic wrote:

And for what you then declared NOT NULL-nost?

Was implied that the Boolean variable can accept three values - true/lie/neopredeleno.
If value  to produce - cannot pass NULL to a NOT NULL.
That would signal that assert fell down because one of entering values beforehand did not check up on .
The same error was expected, if the check condition is not set absolutely not.
It appeared that NULL and UNKNOWN are different things.
On the other hand, LNNVL (NULL) and LNNVL (NULL=1) too accept different values, so...

4

Re: BOOLEAN NOT NULL

BOOLEAN NOT NULL wrote:

It appeared that NULL and UNKNOWN are different things.

You line did not understand.

5

Re: BOOLEAN NOT NULL

Elic wrote:

it is passed...
You line did not understand.

But you understand and even can justify?

6

Re: BOOLEAN NOT NULL

BOOLEAN NOT NULL wrote:

But you understand and even can justify?

Be easier. Can to you and people will be pulled.

7

Re: BOOLEAN NOT NULL

BOOLEAN NOT NULL;
You answer the questions not asked to you.
The being put a question in the answer

Elic wrote:

And for what you then declared NOT NULL-nost?

BOOLEAN NOT NULL wrote:

Instead of ORA-06502 it was expected UNKNOWN.
Or it is logical??
....
By the way, the last two errors arise even if a body the invalid.

It to you answered:

Elic wrote:

the Optimizing compiler

I will translate you:
In a call:

EXEC PKG.ASSERT_NN (NULL);

Null is a literal.
And the body of a packet for decision-making that the call does not correspond to the specification of a method declared in the interface assert is not required to the compiler
Therefore you receive a compile-time error, instead of executions.

BOOLEAN NOT NULL wrote:

On the other hand, LNNVL (NULL) and LNNVL (NULL=1) too accept different values, so...

What there was, but LNNVL (NULL) cannot accept value of passed-in parameter Null at all. Time cannot accept argument, means cannot give result.
This call not "different value" with LNNVL (NULL=1), and it is simple does not work.