Boolean data type with If statement : Boolean « Data Type « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » Data Type » Boolean 
Boolean data type with If statement
   
SQL> SET SERVEROUTPUT ON SIZE 1000000
SQL> <<default_test>>
  2  DECLARE
  3     lv_first_num      NUMBER(10DEFAULT 0;    -- Defaulted to 0
  4     lv_second_num     NUMBER(10:= 10;        -- Defaulted to 10
  5     lv_third_num      NUMBER(10);              -- Defaulted to NULL
  6     lv_processed_bln  BOOLEAN DEFAULT FALSE;   -- Defaulted to FALSE
  7     lv_complete_bln1  BOOLEAN;                 -- Defaulted to NULL
  8     lv_complete_bln2  BOOLEAN;                 -- Defaulted to NULL
  9  BEGIN
 10     DBMS_OUTPUT.PUT_LINE('lv_first_num:      ' ||
 11               TO_CHAR(lv_first_num)  ||
 12               CHR(10|| 'lv_second_num:     ' ||
 13               TO_CHAR(lv_second_num||
 14               CHR(10|| 'lv_third_num:      ' ||
 15               TO_CHAR(lv_third_num)  ||
 16               CHR(10|| 'lv_processed_bln:  ' |'FALSE' ||
 17               CHR(10|| 'lv_complete_bln1:  ' |''      ||
 18               CHR(10|| 'lv_complete_bln2:  ' |''      ||
 19               CHR(10||
 20               'default_test.lv_second_num: ' ||
 21               TO_CHAR(default_test.lv_second_num|| CHR(10));
 22     DBMS_OUTPUT.PUT_LINE('Is lv_second_num > lv_third_num?');
 23     IF lv_second_num > lv_third_num THEN
 24        DBMS_OUTPUT.PUT_LINE('lv_second_num > lv_third_num' || CHR(10));
 25     ELSE
 26        DBMS_OUTPUT.PUT_LINE('lv_second_num < lv_third_num' || CHR(10));
 27     END IF;
 28     DBMS_OUTPUT.PUT_LINE('Is lv_first_num = lv_third_num?');
 29     IF lv_first_num = lv_third_num THEN
 30        DBMS_OUTPUT.PUT_LINE('lv_first_num = lv_third_num');
 31     ELSE
 32        DBMS_OUTPUT.PUT_LINE('lv_first_num <> lv_third_num');
 33     END IF;
 34     DBMS_OUTPUT.PUT_LINE('Is lv_complete_bln1 = TRUE?');
 35     IF lv_complete_bln1 THEN
 36        DBMS_OUTPUT.PUT_LINE('lv_complete_bln1 = TRUE');
 37     ELSE
 38        DBMS_OUTPUT.PUT_LINE('lv_complete_bln1 <> TRUE');
 39     END IF;
 40     DBMS_OUTPUT.PUT_LINE('Is NOT lv_complete_bln1 = TRUE?');
 41     IF NOT lv_complete_bln1 THEN
 42        DBMS_OUTPUT.PUT_LINE('NOT lv_complete_bln1 = TRUE');
 43     ELSE
 44        DBMS_OUTPUT.PUT_LINE('NOT lv_complete_bln1 <> TRUE');
 45     END IF;
 46     DBMS_OUTPUT.PUT_LINE('Is lv_complete_bln1 = lv_complet_bln2?');
 47     IF lv_complete_bln1 = lv_complete_bln2 THEN
 48        DBMS_OUTPUT.PUT_LINE('lv_complete_bln1 = lv_complete_bln2');
 49     ELSE
 50        DBMS_OUTPUT.PUT_LINE('lv_complete_bln1 <> lv_complete_bln2');
 51     END IF;
 52  END default_test;
 53  /
lv_first_num:      0
lv_second_num:     10
lv_third_num:
lv_processed_bln:  FALSE
lv_complete_bln1:
lv_complete_bln2:
default_test.lv_second_num: 10

Is lv_second_num > lv_third_num?
lv_second_num < lv_third_num

Is lv_first_num = lv_third_num?
lv_first_num <> lv_third_num
Is lv_complete_bln1 = TRUE?
lv_complete_bln1 <> TRUE
Is NOT lv_complete_bln1 = TRUE?
NOT lv_complete_bln1 <> TRUE
Is lv_complete_bln1 = lv_complet_bln2?
lv_complete_bln1 <> lv_complete_bln2

PL/SQL procedure successfully completed.

SQL>

   
    
  
Related examples in the same category
1. PL/SQL BOOLEAN datatypes accept only TRUE, FALSE, NULL
2. Define and use boolean value
3. Use the NVL() against a non-initialized BOOLEAN variable:
4. Boolean literals
5. Boolean expressions in where clause
6. Assign a value to a variable of type boolean. Don't use quotes around the value like this
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.