Define and call a function : Function Definition « Store Procedure Function « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Cursor
6. Data Type
7. Date Timezone
8. Hierarchical Query
9. Index
10. Insert Delete Update
11. Numeric Math Functions
12. Object Oriented Database
13. PL SQL
14. Regular Expressions
15. Report Column Page
16. Result Set
17. Select Query
18. Sequence
19. SQLPlus
20. Store Procedure Function
21. Subquery
22. System Tables
23. Table
24. Table Joins
25. Trigger
26. User Previliege
27. View
28. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Oracle PL / SQL » Store Procedure Function » Function Definition 
Define and call a function



SQL>
SQL>
SQL> -- A function block.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2     temp  NUMBER;
  3
  4  FUNCTION iifn(boolean_expression IN BOOLEAN,
  5                true_number IN NUMBER,
  6                false_number IN NUMBER)
  7  RETURN NUMBER IS
  8  BEGIN
  9       IF boolean_expression THEN
 10         RETURN true_number;
 11       ELSIF NOT boolean_expression THEN
 12         RETURN false_number;
 13       ELSE
 14         RETURN NULL;
 15       END IF;
 16  END;
 17
 18  BEGIN
 19     DBMS_OUTPUT.PUT_LINE(iifn(1,1,0));
 20     DBMS_OUTPUT.PUT_LINE(iifn(3,1,0));
 21
 22     temp := iifn(null,1,0);
 23     IF temp IS NULL THEN
 24       DBMS_OUTPUT.PUT_LINE('NULL');
 25     ELSE
 26       DBMS_OUTPUT.PUT_LINE(temp);
 27     END IF;
 28  END;
 29  /
1
0
NULL

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
SQL>
           
       
Related examples in the same category
1. Define and use function in select clause
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.