PL/SQL stands for Procedural Language Extension to SQL. PL/SQL extends SQL by ad
ID: 651728 • Letter: P
Question
PL/SQL stands for Procedural Language Extension to SQL. PL/SQL extends SQL by adding programming structures and subroutines available in any high-level language. In this chapter you will see examples that illustrate the syntax and rules of the language.
PL/SQL is use for both server-side and client-side development. For example database triggers on the server-side and logic behind an Oracle Developer tool on the client-side can be written using PL/SQL. In addition PL/SQL can be used to develop applications for browsers such as netscape and internet explorer when used in conjunction with the Oracle Application Server and the PL/SQL web Development Toolkit.
A. Calculate the diameter of a circle. The value of the radius should be provided with the help of a substitution variable. After the diameter of the circle is calculated display it on the screen. Submit the PL/SQL code.
Explanation / Answer
First open a file from sql> prompt
i.e, sql>ed filename.sql
/* PROGRAM FOR CACULATION OF DIAMETER OF CIRCLE*/
DECLARE /*Declaring variables*/
radius number := &radius; /* Take input from keyboard*/
diameter number;
BEGIN /* procedure begins*/
diameter:=radius*2; /*Calcuation of diameter*/
dbms_output.put_line(' Diameter of circle is : '|| diameter) ; /*output with message and variable*/
END; /*ends here*/
/*Save the program after typing above and execute as follows:
sql> run filename.sql */
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.