Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Oracle PLSQL : Data types: Boolean



BOOLEAN Data Type

The PL/SQL data type BOOLEAN stores logical values, which are the Boolean values
     TRUE and FALSE and the value NULL.
      NULL represents an unknown value.

The syntax for declaring an BOOLEAN variable is:

variable_name BOOLEAN
The only value that you can assign to a BOOLEAN variable is a BOOLEAN expression.

Because SQL has no data type equivalent to BOOLEAN, you cannot:

  • Assign a BOOLEAN value to a database table column
  • Select or fetch the value of a database table column into a BOOLEAN variable

Use a BOOLEAN value in a SQL function

Use a BOOLEAN expression in a SQL statement, except as an argument to a PL/SQL function invoked in a SQL query, or in a PL/SQL anonymous block.


CREATE PROCEDURE p_boolean (b BOOLEAN)
AS
BEGIN
DBMS_OUTPUT.put_line (
CASE
WHEN b IS NULL THEN 'Unknown'
WHEN b THEN 'Yes'
WHEN NOT b THEN 'No'
END
);
END;
/
BEGIN
p_boolean(TRUE);
p_boolean(FALSE);
p_boolean(NULL);
END;
/
Result:
Yes
No
Unknown


This post first appeared on EBiz Integration Technics, please read the originial post: here

Share the post

Oracle PLSQL : Data types: Boolean

×

Subscribe to Ebiz Integration Technics

Get updates delivered right to your inbox!

Thank you for your subscription

×