Q:

Write a PL/SQL block to create a procedure using the "IS [NOT] NULL Operator" and show NOT operator returns the opposite of its operand, unless the operand is NULL

0

Write a PL/SQL block to create a procedure using the "IS [NOT] NULL Operator" and show NOT operator returns the opposite of its operand, unless the operand is NULL.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

CREATE OR REPLACE PROCEDURE pri_bool(
  boo_name   VARCHAR2,
  boo_val    BOOLEAN
) IS
BEGIN
  IF boo_val IS NULL THEN
    DBMS_OUTPUT.PUT_LINE( boo_name || ' = NULL');
  ELSIF boo_val = TRUE THEN
    DBMS_OUTPUT.PUT_LINE( boo_name || ' = TRUE');
  ELSE
    DBMS_OUTPUT.PUT_LINE( boo_name || ' = FALSE');
  END IF;
END;
/

Now call the procedure pri_bool:

PL/SQL Code:

DECLARE
  PROCEDURE pri_not_m (
    m  BOOLEAN
  ) IS
  BEGIN
    pri_bool ('m', m);
    pri_bool ('NOT m', NOT m);
  END pri_not_m;
 
BEGIN
DBMS_OUTPUT.PUT_LINE('------------- FOR m TRUE ---------------------');
  pri_not_m (TRUE);
DBMS_OUTPUT.PUT_LINE('------------- FOR m FALSE ---------------------');
  pri_not_m (FALSE);
DBMS_OUTPUT.PUT_LINE('------------- FOR m NULL ---------------------');
  pri_not_m (NULL);
END;
/

Sample Output:

------------- FOR m TRUE ---------------------
m = TRUE
NOT m = FALSE
------------- FOR m FALSE ---------------------
m = FALSE
NOT m = TRUE
------------- FOR m NULL ---------------------
m = NULL
NOT m = NULL

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now