O'Reilly logo

Oracle by Elena Silvestrova Rakhimov, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D Answers to the Try It Yourself Sections

Chapter 1,“PL/SQL Concepts”

1) To calculate the area of a circle, you must square the circle’s radius and then multiply it by π. Write a program that calculates the area of a circle. The value for the radius should be provided with the help of a substitution variable. Use 3.14 for the value of π. After the area of the circle is calculated, display it on the screen.

ANSWER: The script should look similar to the following:

SET SERVEROUTPUT ONDECLARE   v_radius NUMBER := &sv_radius;   v_area NUMBER;BEGIN   v_area := POWER(v_radius, 2) * 3.14;   DBMS_OUTPUT.PUT_LINE      ('The area of the circle is: '||v_area);END;

In this exercise, you declare two variables, v_radius and v_area, to store the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required