Temperature package: convert Celsius to Fahrenheit back, forth : Utility Function « Stored Procedure Function « 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 » Stored Procedure Function » Utility Function 
Temperature package: convert Celsius to Fahrenheit back, forth
   

SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE temperature IS
  2     PROCEDURE Temperature_Conversion degree number,cf varchar2);
  3     FUNCTION Celsius_to_Fahrenheit degree NUMBERReturn Number;
  4     FUNCTION Fahrenheit_to_Celsius degree NUMBERReturn Number;
  5  END temperature;
  6  /

Package created.

SQL>
SQL> CREATE OR REPLACE PACKAGE BODY temperature AS
  2
  3  PROCEDURE temperature_conversion (degree number,cf varchar2IS
  4      buffer NUMBER := 0;
  5  BEGIN
  6      IF cf = 'C'
  7      THEN
  8          buffer := TEMPERATURE.Celsius_to_Fahrenheit(degree);
  9          DBMS_OUTPUT.PUT_LINE('Fahrenheit = ' || buffer);
 10          RETURN;
 11      ELSIF cf = 'F'
 12      THEN
 13          buffer := TEMPERATURE.Fahrenheit_to_Celsius(degree);
 14          DBMS_OUTPUT.PUT_LINE('Celsius = ' || buffer);
 15          RETURN;
 16      END IF;
 17      DBMS_OUTPUT.PUT_LINE('Bad Temperature Conversion Code: ' || cf);
 18  RETURN;
 19
 20  END temperature_conversion;
 21
 22      FUNCTION celsius_to_fahrenheit (degree NUMBER)
 23      RETURN NUMBER IS
 24      buffer NUMBER;
 25
 26      BEGIN
 27         buffer := (degree * 9/532;
 28         RETURN buffer;
 29      END celsius_to_fahrenheit;
 30
 31      FUNCTION fahrenheit_to_celsius (degree NUMBER)
 32      RETURN NUMBER IS
 33      buffer NUMBER;
 34
 35      BEGIN
 36         buffer := (5/9(degree - 32);
 37         RETURN buffer;
 38      END fahrenheit_to_celsius;
 39
 40  END temperature;
 41  /

Package body created.

SQL>
SQL>

   
    
    
  
Related examples in the same category
1. Your own month add method
2. Raise power function
3. Raise pay level
4. Validate date value format
5. Function to update null value
6. Function to count tab
7. Calculate average grade
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.