Documente Academic
Documente Profesional
Documente Cultură
Section 1
Processing
Procedural (*)
Primary
Proprietary
PL/SQL and SQL can be used with many types of databases, including Oracle.
PL/SQL allows basic program logic and control flow to be combined with SQL
statements. (*)
declarative
nondeclarative
procedural (*)
low level
4. Using Oracle Application Express, you can create Web applications that include PL/SQL.
True or False?
True (*)
False
5. Comparing PL/SQL with other languages such as C and Java, which of the following
statements is true?
PL/SQL is easier to learn and does not require an Oracle database or tool
Exception handling code tells your program what to do when an error is encountered.
BEGIN
END;
procedure
subroutine
function
anonymous (*)
1. END;
2. EXCEPTION
3. DECLARE
4. BEGIN
2,1,4,3
3,4,2,1 (*)
3,2,4,1
4,3,2,1
10.Which component of Oracle Application Express is used to enter and run SQL statements
and PL/SQL blocks?
Application Builder
Utilities
Object Browser
DECLARE
END; (*)
EXCEPTION
BEGIN (*)
DBMS_OUTPUT.PUT_LINE
12. In which part of the PL/SQL block are declarations of variables defined?
Executable
Exception
Declarative (*)
Definition
13. Errors are handled in the Exception part of the PL/SQL block. True or False?
True (*)
False
DECLARE
Correct.
15. Variables can be used in the following ways in a PL/SQL block. (Choose two.)
To comment code.
16. When a variable is defined using the NOT NULL keywords, the variable must contain a
value. True or False?
True (*)
False
17. Identify which of the following assignment statements are valid. (Choose three.)
v_last_name := Chandra;
DECLARE
Correct.
19. Which of the following are disadvantages of implicit data type conversions? (Choose two.)
If Oracle changes the conversion rules in the future, your code may not work any more (*)
1 DECLARE
2 x NUMBER;
3 BEGIN
4 x:= '300';
5 END;
TO_CHAR(sysdate)
TO_DATE(sysdate)
True
False (*)
23.When you use a function to convert data types in a PL/SQL program, it is called ______
conversion.
Explicit (*)
Implicit
TO_CHAR
DECLARE
a VARCHAR2(10) := '333';
b VARCHAR2(10) := '444';
c PLS_INTEGER;
d VARCHAR2(10);
BEGIN
c := TO_NUMBER(a) + TO_NUMBER(b);
d := a || b;
DBMS_OUTPUT.PUT_LINE(c);
DBMS_OUTPUT.PUT_LINE(d);
END;
Nothing. The code will result in an error.
Character functions
Operators
26. Examine the following code. What is the final value of V_MYVAR ?
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 1 + 2 * 3;
v_myvar := v_myvar * 2;
END;
81 49 14 (*) 18
27. 1. Null
2. False
3. True
4. 0
2 and 3
2, 3 and 4
1, 2 and 3 (*)
1, 2, 3 and 4
28. You need to declare a variable to hold a value which has been read from the SALARY
column of the EMPLOYEES table. Which of the following is an advantage of declaring the
variable as: employees.salary%TYPE ?
If the SALARY column is ALTERed later, the PL/SQL code need not be changed. (*)
29. If you are using the %TYPE attribute, you can avoid hard coding the
Table name
Column name
Constraint
30. What is the data type of the variable V_DEPT_TABLE in the following declaration?
DECLARE
Scalar
Composite (*)
LOB
Scalar
Composite
Reference
LOB (*)
32. A collection is a composite data type. True or False?
True (*)
False
33. Delimiters are _____ that have special meaning to the Oracle database.
identifiers
variables
symbols (*)
34. Which statements about lexical units are true? (Choose two.)
They are optional but can make a PL/SQL block execute faster
They are sequences of characters including letters, digits, tabs, returns and symbols (*)
True
False (*)
36. When an exception occurs within a PL/SQL block, the remaining statements in the
executable section of the block are skipped. True or False?
True (*)
False
37. when nested blocks are used, which blocks can or must be labeled?
The inner block must be labeled, the outer block can be labeled.
The outer block must be labeled if it is to be referred to in the inner block. (*)
38. What will be displayed when the following code is executed?
DECLARE
x VARCHAR2(6) := 'Chang';
BEGIN
DECLARE
x VARCHAR2(12) := 'Susan';
BEGIN
x := x || x;
END;
DBMS_OUTPUT.PUT_LINE(x);
END;
Susan
Chang (*)
ChangChang
SusanChang
39. An exception occurs within the inner block of two nested blocks. The inner block does
not have an EXCEPTION section. What always happens
Both blocks fail and an error message is displayed by the calling environment
DECLARE
BEGIN
DECLARE
varB NUMBER := 8;
BEGIN
END;
DBMS_OUTPUT.PUT_LINE(varB);
END;
FROM employees
WHERE employee_id=100;
What is the value of SQL%ISOPEN immediately after the SELECT statement is executed?
True
False (*)
Null
42. There are no employees in Department 77. What will happen when the following block is
executed?
BEGIN
WHERE department_id=77;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT)
END;
A NULL is displayed.
An exception is raised because the block does not contain a COMMIT statement.
43. Which is the correct way to erase one row from a table?
REMOVE employee_id=100
FROM employees;
WHERE employee_id=100;
TRUNCATE employees
WHERE employee_id=100;
44. Which one of these SQL statements can be directly included in a PL/SQL executable
block?
WHERE department_id=60;
DECLARE
BEGIN
END;
No rows. (*)
46. Which one of these SQL statements can be directly included in a PL/SQL executable
block?
WHErE employee_id=100;
• DESCRIBE employees;
• UPDATE employees
DECLARE
v_holdit employees.last_name%TYPE;
BEGIN ...
DECLARE
v_salary employees.salary%TYPE;
BEGIN
Only one
BEGIN
VALUES ('NV','Neverland');
COMMIT;
COMMIT;
ROLLBACK;
END;
You have nothing new; the last ROLLBACK undid the INSERTs.
You have the rows added twice; there are four new rows.