Oracle 1-4,6
Oracle 1-4,6
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 2
(Answer all questions in this section)
6. Which of the following is NOT a character data type?
LONG
CHAR
VARCHAR2
BOOLEAN (*)
Correct
(1/1) Points
7. Is the following variable declaration correct or not?
DECLARE
test NUMBER(5);
Correct. (*)
Not correct.
Incorrect. Refer to Section 2 Lesson 1.
(0/1) Points
8. When a variable is defined using the NOT NULL keywords, the variable must
contain a value. True or False?
True (*)
False
Correct
(1/1) Points
9. What characters must enclose non-numeric literal values?
Single quotes: ' ' (*)
Double quotes: " "
Parentheses: ()
Correct
(1/1) Points
10. Delimiters are _____ that have special meaning to the Oracle database.
symbols (*)
identifiers
variables
Correct
(1/1) Points
Previous Page 2 of 3 Next
11. A variable defined in an outer block is global to the outer block and local to
the inner block. True or False?
True
False (*)
Incorrect. Refer to Section 2 Lesson 6.
(0/1) Points
12. If a variable is defined with the same name in both an inner and outer block,
and referenced in the outer block, it will reference the ___________ block value of
the variable.
Inner
Neither - can't define a variable with the same name in both blocks
Outer (*)
Incorrect. Refer to Section 2 Lesson 6.
(0/1) Points
13. The LENGTH and ROUND functions can be used in PL/SQL statements. True
or False?
True (*)
False
Correct
(1/1) Points
14. The implicit data type conversion at Point A may not work correctly. Why not?
DECLARE
v_mydate DATE;
BEGIN
V_MYDATE := '29-Feb-2004'; -- Point A
END;
Oracle cannot implicitly convert a character string to a date, even if the string
contains a valid date value (*)
There are only 28 days in February
If the database language is not English, 'Feb' has no meaning.
V_MYDATE has been entered in uppercase
Correct
(1/1) Points
15. TO_NUMBER, TO_CHAR, and TO_DATE are all examples of:
Explicit conversion functions (*)
Implicit conversion functions
Character functions
Operators
Correct
1. Which SQL statement can NOT use an implicit cursor?
A SELECT statement that returns multiple rows (*)
An UPDATE statement
A SELECT statement that returns one row
A DELETE statement
Correct
(1/1) Points
2. Employee_id 999 does not exist. What will happen when the following code is
executed?
DECLARE
employee_id employees.employee_id%TYPE := 999;
BEGIN
UPDATE employees
SET salary = salary * 1.1
WHERE employee_id = employee_id;
END;
NO 3
YES 3 (*)
YES 1
Nothing will be displayed. The block will fail because you cannot use implicit
cursor attributes directly in a call to DBMS_OUTPUT.PUT_LINE.
Correct
(1/1) Points
4. A variable is declared as:
DECLARE
v_holdit employees.last_name%TYPE;
BEGIN ...
SELECT last_name
INTO v_holdit
FROM employees
WHERE employee_id=100; (*)
SELECT salary
INTO v_holdit
FROM employees
WHERE employee_id=100;
SELECT last_name
INTO v_holdit
FROM employees;
SELECT *
INTO v_holdit
FROM employees;
Incorrect. Refer to Section 3 Lesson 2.
(0/1) Points
5. Which of the following is NOT a valid guideline for retrieving data in PL/SQL?
Specify the same number of variables in the INTO clause as database columns in
the SELECT clause.
Do NOT use a WHERE clause in SELECT statements. (*)
Where possible, declare variables using the %TYPE attribute.
Terminate the SQL statement with a semicolon (;)
Correct
6. Which one of these SQL statements can be directly included in a PL/SQL
executable block?
UPDATE employees
SET last_name='Smith'; (*)
DROP TABLE employees;
DESCRIBE employees;
SELECT last_name FROM employees
WHERE employee_id=100;
Correct
(1/1) Points
7. Does PL/SQL allow you to have a variable with the same name as a database
column?
Yes (*)
No
Correct
(1/1) Points
8. Which one of these SQL statements can be directly included in a PL/SQL
executable block?
SELECT salary FROM employees
WHERE department_id=60;
DROP TABLE locations;
CREATE TABLE new_emps (last_name VARCHAR2(10), first_name VARCHAR2(10));
DELETE FROM employees
WHERE department_id=60; (*)
Correct
(1/1) Points
9. Which of the following best describes a database transaction?
A related set of SQL DML statements which must be executed either completely
or not at all (*)
A single SQL statement that updates multiple rows of a table
A SELECT statement based on a join of two or more database tables
All the DML statements in a single PL/SQL block
Correct
(1/1) Points
10. Examine the following code: BEGIN
INSERT INTO animals VALUES ('aa','aardvarks');
SAVEPOINT sp_1;
INSERT INTO animals VALUES ('bb','big birds');
SAVEPOINT sp_2;
ROLLBACK TO sp_1;
INSERT INTO animals VALUES ('cc','cool cats');
COMMIT;
END;
Which row(s) will be in the ANIMALS table after this block is executed?
aardvaarks and cool cats (*)
cool cats
aardvaarks, big birds and cool cats
big birds and cool cats
Correct
11. You want to modify existing rows in a table. Which of the following are NOT
needed in your SQL statement?
A MODIFY clause. (*)
A new value for the column you want to modify (this can be an expression or a
subquery).
The name of the table.
The name of the column(s) you want to modify.
An UPDATE clause.
Correct
(1/1) Points
12. The MERGE statement will INSERT or DELETE rows in a target table based on
matching values in a source table. True or False?
True
False (*)
Incorrect. Refer to Section 3 Lesson 1.
(0/1) Points
13. What is wrong with the following statement?
MERGE INTO emps e
USING new_emps ne
ON (e.employee_id = ne.employee_id)
WHEN MATCHED
THEN UPDATE
SET ne.salary = e.salary
WHEN NOT MATCHED
THEN INSERT VALUES
(ne.employee_id, ne.first_name, ne.last_name, .... ne.salary, ....);
The UPDATE clause must include the target table name: UPDATE emps SET ....
The SET clause is trying to update the source table from the target table. (*)
The INSERT clause must include a column list as well as a list of column values.
Nothing is wrong, the statement will execute correctly.
Incorrect. Refer to Section 3 Lesson 1.
(0/1) Points
14. Which of the following will delete all employees who work in the Sales
department?
DELETE FROM employees
WHERE department_id =
SELECT department_id
FROM departments
WHERE department_name = 'Sales';
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name = 'Sales'); (*)
DELETE (SELECT department_id
FROM departments
WHERE department_name = 'Sales')
FROM employees;
DELETE FROM employees e, departments d
WHERE e.department_id = d.department_id
AND department_name = 'Sales';
Correct
(1/1) Points
15. What will happen when the following statement is executed?
UPDATE employees
SET salary = 5000, commission_pct = NULL WHERE department_id = 50; ;
All employees who have a salary of 5000 have their commission percentage set
to NULL.
The statement fails because you cannot modify more than one column in a
single UPDATE statement.
All employees in department 50 have their salary changed to 5000 and their
commission percentage set to NULL. (*)
The statement fails because you cannot use NULL in the SET clause.
Correct
1. What will be the value of v_result after the following code is executed?
DECLARE
v_grade CHAR(1) := NULL;
v_result VARCHAR2(10);
BEGIN
CASE
WHEN v_grade IN ('A', 'B') THEN v_result := 'Very Good';
WHEN v_grade IN ('E','F') THEN v_result := 'Poor';
ELSE v_result := 'In Between';
END CASE;
DBMS_OUTPUT.PUT_LINE(v_result);
END;
Very Good
In Between (*)
Poor
Null
Correct
(1/1) Points
2. Look at the following code:
DECLARE
x BOOLEAN := FALSE;
y BOOLEAN := FALSE;
z BOOLEAN ;
BEGIN
z := (x OR NOT y);
-- Line A
....
END;
What is the value of Z at Line A?
True (*)
NULL
An error will occur because you cannot combine two Boolean variables using
"NOT".
False
Correct
(1/1) Points
3. What will be the value of v_sal_desc after the following code is executed?
DECLARE
v_salary NUMBER(6,2) := NULL;
v_sal_desc VARCHAR2(10);
BEGIN
CASE
WHEN v_salary < 10000 THEN v_sal_desc := 'Low Paid';
WHEN v_salary >= 10000 THEN v_sal_desc := 'High Paid';
END CASE;
END;
Low Paid
The code will fail and return an unhandled exception error to the host
environment (*)
High Paid
Null
Correct
(1/1) Points
4. What will be displayed when the following block is executed?
DECLARE
x NUMBER(6) := 0 ;
BEGIN
FOR i IN 1..10 LOOP
FOR j IN 1..5 LOOP
x := x+1 ;
END LOOP;
END LOOP;
DBMS_OUTPUT.PUT_LINE(x);
END;
50 (*)
5
10
15
Correct
(1/1) Points
5. What statement allows you to exit the inner loop at Point A in the following
block?
DECLARE
v_outer_done CHAR(3) := 'NO';
v_inner_done CHAR(3) := 'NO';
BEGIN
LOOP -- outer loop
...
LOOP -- inner loop
...
v_inner_done := 'YES';
... -- Point A
...
END LOOP;
...
EXIT;
...
END LOOP;
END;
In this code it is valid for each loop to have it's own EXIT statement. True or
False?
True (*)
False
Correct
(1/1) Points
7. What will be displayed when this block is executed?
DECLARE
v_count NUMBER := 10;
v_result NUMBER;
BEGIN
LOOP
v_count := v_count - 1;
EXIT WHEN v_count < 5;
v_result := v_count * 2;
END LOOP;
DBMS_OUTPUT.PUT_LINE(v_result);
END;
NULL
12
10 (*)
8
Correct
(1/1) Points
8. Look at this code:
DECLARE
v_bool BOOLEAN := TRUE;
v_date DATE;
BEGIN
LOOP
EXIT WHEN v_bool;
SELECT SYSDATE INTO v_date FROM dual;
END LOOP;
END;
v_emp_dept_rec emp_dept_type;
four (*)
one
two
three
Correct
(1/1) Points
12. Which of the following statements about user-defined PL/SQL records is NOT
true?
It must contain one or more components, but all the components must have
scalar datatypes. (*)
It is not the same as a row in a database table.
It can be defined as NOT NULL.
It can be used as an OUT parameter in a package procedure.
It can be a component of another PL/SQL record.
Correct
(1/1) Points
13. You can store a whole record in a single variable using %ROWTYPE or by
creating your own record structure as a type and then declaring a variable of
that type. True or False?
True (*)
False
Correct
(1/1) Points
14. Which of the following will successfully create a record type containing two
fields, and a record variable of that type?
TYPE person_type IS RECORD
(l_name VARCHAR2(20),gender CHAR(1));
person_rec person_type; (*)
TYPE person_type IS (l_name VARCHAR2(20),gender CHAR(1));
person_rec TYPE person_type;
TYPE person_type IS (l_name VARCHAR2(20), gender CHAR(1));
person_rec person_type;
TYPE person_type IS RECORD
(l_name VARCHAR2(20), gender CHAR(1));
person_rec TYPE person_type;
Correct
(1/1) Points
15. You can use %ROWTYPE with tables and views. True or False?
True (*)
False
Correct