Prentice Hall Oracle Plsql By Example 3Rd Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Prentice Hall Oracle Plsql By Example 3Rd Edition [Electronic resources] - نسخه متنی

Benjamin Rosenzweig

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید









A1:

Answer: Your answer should look similar to the following:



SET SERVEROUTPUT ON
DECLARE
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 values for the radius of the circle and its area, respectively. Next, you compute the value for the variable v_area with the help of the built-in function POWER and the value of the v_radius. Finally, you display the value of the v_area on the screen.

Assume that number 5 has been entered for the value of the variable v_radius. Then the script produces the following output:



Enter value for sv_radius: 5

old 2: v_radius NUMBER := &sv_radius;

new 2: v_radius NUMBER := 5;

The area of the circle is: 78.5

PLSQL procedure successfully completed.


2)

Rewrite the script ch02_2b.sql, version 2.0. In the output produced by the script, extra spaces appear after the day of the week. The new script must remove the extra spaces after the day of the week.

The current output:



Today is Friday , 23:09

The new output should have the format as shown:



Today is Friday, 23:09

A2:

Answer: Your answer should look similar to the following. All changes are shown in bold letters:



SET SERVEROUTPUT ON
DECLARE
v_day VARCHAR2(20);
BEGIN

v_day := TO_CHAR(SYSDATE, 'fmDay, HH24:MI');
DBMS_OUTPUT.PUT_LINE ('Today is '|| v_day);
END;

In this script, you modify the format in which you would like to display the date. Notice that the word 'Day' is now prefixed by the letters 'fm'. These letters guarantee that extra spaces will be removed from the name of the day. When run, this exercise produces the following output:



Today is Tuesday, 18:54

PLSQL procedure successfully completed.



/ 289