Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Kazybek Auyez, CS-1901

2-1

1. A) PL/SQL Subprogram
B) Executable
C) Parameters
2. valid
invalid
invalid
valid
3. A
4.
A

B. In this code we output the number of characters which are contained in variable

5.
2-2

1.

2.
3.

2-3

1. Data type is very important, because it allows us to specify a storage format and its range
of values.
2. Scalar; Composite; Object
3. Varchar; Date; Integer
4. Boolean 5
5. LOB
6.
7.

2-4

1.
a.

b. naming convention is not accurate


c.
2. Better put v_ before the names of variables
3. v_country_name VARCHAR2(50);
v_region_id NUMBER(6, 2);
DECLARE
v_country_name countries.county_name%TYPE;
v_region_id countries.region_id%TYPE;
BEGIN
SELECT country_name, region_id INTO v_country_name, v_region_id
FROM countries WHERE country_name = 'Japan';
DBMS_OUTPUT.PUT_LINE('The region id in '|| v_country_name || ' is ' || v_region_id
|| '.');
END;
4. The %TYPE attribute items changes, declaration is also updated.
5. a.
DECLARE
v_today DATE;
v_tomorrow v_today%TYPE;
b.
DECLARE
v_today DATE;
v_tomorrow v_today%TYPE:=v_today+1;
BEGIN
DBMS_OUTPUT.PUT_LINE(‘Hello world’);
DBMS_OUTPUT.PUT_LINE(v_today);
DBMS_OUTPUT.PUT_LINE(v_tomorrow);
END;

2.5

1. a. 123456
b. 579
c. PL/SQL implicitly converted VARCHAR2 to NUMBER format
2.

3.
4.

5.
a. 11
b. 11
6. TRUE, because the condition is FALSE, so NOT FALSE is TRUE
7. Depends on the environment
May experience a negative impact on performance

2.6

1. a. 2
b. Western Europe
c. 601
d. Product 10012 is in stock
e. Out of range of the block
2. a. Declaration of the inner block’s order is higher than the outer one
b. Declaration of the inner block cannot be taken by the outer one
2.7
1. DECLARE
myvar1 VARCHAR2(20);
myvar2 NUMBER(4);
BEGIN
SELECT country_name INTO myvar1
FROM countries WHERE country_id = 1246;
myvar2 := 1234;
myvar2 := myvar2 * 2;
DBMS_OUTPUT.PUT_LINE(myvar1);
END;

You might also like