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

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

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

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

Benjamin Rosenzweig

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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



Lab 2.2 Exercises


2.2.1 Use Substitution Variables


In this exercise, you will calculate the square of a number. The value of the number will be provided with the help of a substitution variable. Then the result will be displayed on the screen.

Create the following PL/SQL script:

-- ch02_1a.sql, version 1.0
SET SERVEROUTPUT ON
DECLARE
v_num NUMBER := &sv_num;
v_result NUMBER;
BEGIN
v_result := POWER(v_num, 2);
DBMS_OUTPUT.PUT_LINE ('The value of v_result is: '||
v_result);
END;

Execute the script, and then answer the following questions:

a)

If the value of v_num is equal to 10, what output is printed on the screen?

b)

What is the purpose of using a substitution variable?

c)

Why is it considered a good practice to enclose substitution variables with single quotes for string datatypes?

2.2.2 Use the DBMS_OUTPUT.PUT_LINE Statement


In this exercise, you will determine the day of the week based on today's date. You will then display the results on the screen.

Create the following PL/SQL script:

-- ch02_2a.sql, version 1.0
SET SERVEROUTPUT ON
DECLARE
v_day VARCHAR2(20);
BEGIN
v_day := TO_CHAR(SYSDATE, 'Day');
DBMS_OUTPUT.PUT_LINE ('Today is '||v_day);
END;

Execute the script, and then answer the following questions:

a)

What was printed on the screen?

b)

What will be printed on the screen if the statement SET SERVEROUTPUT OFF is issued? Why?

c)

How would you change the script to display the time of the day as well?


    / 289