PL/SQL DataType: Procedure to accepts a BOOLEAN parameter and uses a CASE statement to print Unknown if the value of the parameter is NULL, Yes if it is TRUE, and No if it is FALSE
PL/SQL DataType: Exercise-4 with Solution
Write a PL/SQL procedure to accepts a BOOLEAN parameter and uses a CASE statement to print Unknown if the value of the parameter is NULL, Yes if it is TRUE, and No if it is FALSE.
Sample Solution:
PL/SQL Code:
CREATE PROCEDURE use_of_boolean (bl BOOLEAN) AUTHID DEFINER
AS
BEGIN
DBMS_OUTPUT.put_line (
CASE
WHEN bl IS NULL THEN 'Unknown'
WHEN bl THEN 'Yes'
WHEN NOT bl THEN 'No'
END
);
END;
/
BEGIN
use_of_boolean(NULL);
use_of_boolean(FALSE);
use_of_boolean(TRUE);
END;
/
Sample Output:
Unknown No Yes PL/SQL procedure successfully completed.
Flowchart:
Improve this sample solution and post your code through Disqus
Previous: Write a PL/SQL block to differenciate between CHAR and VARCHAR2 datatype.
Next: Write a PL/SQL program to show the upper limit of PLS_INTEGER.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/plsql-exercises/datatype/plsql-datatype-exercise-4.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics