Celsius to Fahrenheit Conversion on Oracle PL/SQL

This article will discuss about Celsius to Fahrenheit Conversion on Oracle PL/SQL. Temperature has a different measurement units such as Celsius, Fahrenheit and Kelvin. If we know the value of one measurement unit then we will be able to determine the value in other units. We call this as a unit conversions. This can be done by doing the conversion in any programming language, one is Oracle PL/SQL. First wee need to know is we must know the formula to convert the units.

The following example will show PL/SQL block to convert the temperature from Celsius to Fahrenheit. The formula used to convert from Celsius to Fahrenheit is 9/5 x Celsius + 32. But before we execute any of PL/SQL syntax, firstly after we do a login process on SQL*Plus me must type the SET SERVEROUTPUT ON commnad (just only one time every session).

DECLARE
        celcius NUMBER;
        fahrenheit NUMBER;
BEGIN
        celcius := &input_celcius;
        fahrenheit := 9/5 * celcius + 32;
        DBMS_OUTPUT.PUT_LINE (celcius ||' Celcius = '||fahrenheit|| ' Fahrenheit');
     END;
     /


Above PL/SQL block will require an input value from keyboard to fill the Celsius value. Celsius value will be converted using the formula 9/5 x Celsius + 32. Suppose that the input given on Celsius is 30, then the output is 86 Fahrenheit.


That's all the explanation about Celsius to Fahrenheit Conversion on Oracle PL/SQL. You should be able to convert other type of conversion as long as you know the formula.

Thank You - Bobsis

No comments

Powered by Blogger.