- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert distance from km to meters and centimeters in PL/SQL
The task is to convert the distance from kilometers to meters and centimeters in PL/SQL.PL/SQL is the extension of SQL which combines the Data manipulation of SQL with the working of procedural language.
According to the problem we should have distance in kilometers whose value we have to convert in meters and centimeters.
As per the conversion rule −
1km = 1000 meters
1km = 100000 centimeters
According to this conversion rule we want the distance to be converted by a logic in PL/SQL.
Input: kilometer = 10 Output: meter = 10000 Centimeter = 1000000 Input: kilometer = 9 Output: meter = 9000 Centimeter = 900000
Approach we will be using
Take the value of the kilometers as an input.
Multiply the value of kilometers by 1000 then store and print the result in meters.
Multiply the value of meters by 100 then store and print the result in centimeters.
--DECLARATION DECLARE KM NUMBER := 4.5; meter NUMBER := 0; Cem NUMBER := 0; --BODY BEGIN meter := km * 1000; Cem := meter * 100; dbms_output.Put_line('The value of 4.5 KM to meters is: ' ||meter); dbms_output.Put_line('The value of 4.5 KM to centimeters is: ' ||cem); END; --BODY END
If we run the above code it will generate the following output −
The value of 4.5 KM to meters is: 4500 The value of 4.5 KM to centimeters is: 450000
- Difference between SQL and PL/SQL
- Difference Between T-SQL and PL-SQL
- What is PL/SQL?
- Print all odd numbers and their sum from 1 to n in PL/SQL
- Reverse a Number in PL/SQL
- How to capture Oracle errors in PL/SQL?
- The distance between the earth and the moon is approximately 384000 km. Express the distance in meters in exponential notation.
- Golang Program to Convert Centimeters into Feet and Inches
- Program for Fibonacci numbers in PL/SQL
- Block of PL/SQL in Oracle DBMS
- Print pyramid of tutorialspoint in PL/SQL
- Explain the PL/SQL Engine in DBMS
- Floyd's triangle in PL/SQL
- Database Wars: MSSQL Server, Oracle PL/SQL and MySQL
- MySQL query to convert height format to centimeters?