Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Tema nr.

1
Observație!
Scrieți rezolvarea direct în acest document!

1. Circle the programming language meeting the criteria


Criteria
3GL PL/SQL SQL
4GL PL/SQL SQL
Is proprietary to Oracle Corporation PL/SQL SQL
Nonprocedural PL/SQL SQL
Procedural PL/SQL SQL
Is ANSI-compliant PL/SQL SQL

2. In the following code, identify and highlight examples of these procedural constructs: variable,
conditional control, SQL statement

DECLARE
v_first_name varchar2(40);
v_last_name varchar2(40);
v_first_letter varchar2(1);
BEGIN
SELECT first_name, last_name into v_first_name, v_last_name
FROM students
WHERE student_id=105;
v_first_letter := get_first_letter(last_name);
IF 'N' > 'v_first_letter' THEN
DBMS_OUTPUT.PUT_LINE('The last name for: '||first_name||' '||last_name||' is
between A and M');
ELSE
DBMS_OUTPUT.PUT_LINE('The last name for: '||first_name||' '||last_name||' is
between N and Z');
END IF;
END;

Variable:
v_first_name varchar2(40);
v_last_name varchar2(40);
v_first_letter varchar2(1);

conditional control:
IF 'N' > 'v_first_letter' THEN

SQL statement:
v_first_letter := get_first_letter(last_name);
3. Complete the following chart defining the syntactical requirements for a PL/SQL block:
Optional or Mandatory?

Optional or Mandatory? Describe what is included in this section


DECLARE optional Various declaration
BEGIN Mandatory SQL and PL/SQL statements
EXCEPTION optional Behavior on errors
END mandatory End of program

4. Which of the following PL/SQL blocks execute successfully? For the blocks that fail, explain
why they fail.

A.
BEGIN
END;
-nu se executa cu succes pt ca nu exista nici o instructiune intre BEGIN si END

B.
DECLARE amount INTEGER(10);
END;
-nu se executa cu succes pt ca lipseste BEGIN, lucru care este obligatoriu intru-un bloc SQL/PL

C.
DECLARE
BEGIN
END;
-nu se executa ptc nu exista nici o instructiune, la fel ca la punctul A

D.
DECLARE amount NUMBER(10);
BEGIN
DBMS_OUTPUT.PUT_LINE(amount);
END;
-este OK

5. Fill in the blanks:


A. PL/SQL blocks that have no names are called anonymus blocks.
B. Procedural and functional are named blocks and are stored in the database.
6. In Application Express, create and execute a simple anonymous block that outputs “Hello
World.”
BEGIN
DBMS_OUTPUT.PUT_LINE(“Hello world!”);
END;

7. Create and execute a simple anonymous block that does the following:
• Declares a variable of datatype DATE and populates it with the date that is six months
from today
• Outputs “In six months, the date will be: <insert date>.”

DECLARE
v date DATE = ADD MONTH(SYSDATE, 6)
BEGIN
DBMS OUTPUT,PUT LINE (‘In six mounths, the date will be’);
DBMS OUTPUT,PUT LINE (v date);
END;

You might also like