UBD01 - Fundamentals
UBD01 - Fundamentals
1
Observație!
Scrieți rezolvarea direct în acest document!
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;
3. Complete the following chart defining the syntactical requirements for a PL/SQL block:
Optional or Mandatory?
A.
BEGIN
END;
-Fail. After begin we must have something NULL;
B.
DECLARE amount INTEGER(10);
END;
-Fail. Because the begin is missing
C.
DECLARE
BEGIN
END;
-Fail. The same sa for block A;
D.
DECLARE amount NUMBER(10);
BEGIN
DBMS_OUTPUT.PUT_LINE(amount);
END;
-SUCCESSFUL
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>.”
BEGIN
SELECT ADD_MONTHS(SYSDATE,6) INTO v_timestamp FROM DUAL;
DBMS_OUTPUT.PUT_LINE('In six months,the date will be:' ||v_timestamp);
END