Professional Documents
Culture Documents
True (*)
False
[Correct] Correct
It must contain one or more components, but all the components must have
scalar datatypes. (*)
Section 1
(Answer all questions in this section)
1. To declare an INDEX BY table, we must first declare a ty
pe and then declare a collection variable of that type. True or False? Mark for
Review
(1) Points
True (*)
False
DROP
FIRST (*)
EXISTS (*)
COUNT (*)
PREVIOUS
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
(*)
DECLARE
TYPE t_depttab IS TABLE OF departments%TYPE
INDEX BY BINARY_INTEGER;
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY NUMBER;
DECLARE
TYPE t_depttab IS INDEX BY TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
100
4096
32767
A record
An INDEX BY table
TOO_MANY_ROWS
ZERO_DIVIDE
NO_DATA_FOUND
Has a standard Oracle error number and a standard name which can be refe
renced in the EXCEPTION section (*)
Has a standard Oracle error number but must be declared and named by the
PL/SQL programmer
User-defined errors
A constraint violation
A NO_DATA_FOUND exception
[Correct] Correct
OTHERS (*)
SQL%ROWCOUNT = 0
NO_DATA_FOUND
ZERO_DIVIDE (*)
OTHER
The code will not execute because PRAGMA EXCEPTION_INIT must be coded in
the DECLARE section. (*)
The code will not execute because the syntax of PRAGMA EXCEPTION_INIT is
wrong.
The code will not execute because the syntax of the INSERT statement is
wrong.
The code will execute and insert error number 02291 into error_log_table
.
The code will fail because we access error message numbers by using SQLE
RRNUM, not SQLCODE.
The code will fail because SQLCODE has not been declared.
The code will fail because we cannot use functions like SQLCODE directly
in a SQL statement. (*)
[Correct] Correct
SQLCODE
SQLERRM (*)
SQL%MESSAGE
SQL_MESSAGE_TEXT
[Correct] Correct
An error occurs during the execution of the block, which disrupts the no
rmal operation of the program. (*)
The programmer forgets to declare a cursor while writing the PL/SQL code
.
[Correct] Correct
3. Which of these exceptions can be handled by an EXCEPTION
section in a PL/SQL block? Mark for Review
(1) Points
Any other kind of exception that can occur within the block
True (*)
False
[Correct] Correct
EXCEPTION
WHEN OTHERS THEN statement_1;
END;
(*)
EXCEPTION
WHEN OTHERS THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
END;
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
END;
(*)
EXCEPTION
WHEN TOO_MANY_ROWS THEN statement_1;
END;
(*)
True (*)
False
[Correct] Correct
Include a WHEN OTHERS handler as the first handler in the exception sect
ion. (*)
Test your code with different combinations of data to see what potential
errors can happen.
The exception handler should test for the named exception NO_DATA_FOUND.
(*)
An exception handler which the user (the programmer) includes in the EXC
EPTION section.
BOOLEAN
VARCHAR2
EXCEPTION (*)
NUMBER
[Correct] Correct
You cannot explicitly raise predefined Oracle Server errors such as NO_D
ATA_FOUND.
Message 1
Message 3
The code will not execute because it contains at least one syntax error.
The code will execute but will return an unhandled exception to the call
ing environment.
(*)
Message 1
Message 2
Message 3
Message 4
Message 1
Message 3
Message 4
True
False (*)
[Correct] Correct
By PRAGMA EXCEPTION_INIT
None of the above. They are raised automatically by the Oracle server.
RAISE application_error;
True (*)
False
[Correct] Correct
True
False (*)
The code will fail to compile because e_inner_excep was declared but nev
er RAISEd.
The code will execute successfully and 'Outer Raised' will be displayed.
The code will propagate the e_outer_excep back to the calling environmen
t (Application Express).
[Correct] Correct
It will fail to compile because you cannot declare more than one excepti
on in the same block.
Message 1
Message 3
Message 4
Message 1
Message 4
(*)
Message 1
30 (*)
100
40
35
25
Section 1
(Answer all questions in this section)
1. Which of the following are characteristics of anonymous
PL/SQL blocks but not PL/SQL subprograms? (Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
True
False (*)
Stored externally
[Incorrect] Incorrect. Refer to Section 8 Lesson 1.
True
False (*)
A SELECT statement
An action (*)
A return of values
[Correct] Correct
The statement will fail because you cannot declare variables such as v_e
mpid inside a procedure.
The statement will fail because the last line of code should be END my_p
roc; (*)
[Correct] Correct
REPLACE
END (*)
BEGIN (*)
DECLARE
EXCEPTION
A and C
A, B, and D (*)
A and B
A only
B and C
[Correct] Correct
True (*)
False
[Correct] Correct
True (*)
False
[Correct] Correct
True
False (*)
They are both names of variables. A parameter is passed into the procedu
re, while an argument is passed out of the procedure.
A literal value
An expression
All of the above (*)
myproc(p_left, p_right);
myproc(v_left, v_right);
myproc(v_left, 30);
They allow values to be passed between the calling environment and the p
rocedure. (*)
p_param
v_param (*)
Smith'
(v_num NUMBER(6,2))
(v_num)
(v_num NUMBER(4,2))
[Correct] Correct
1. What are the three parameter modes for procedures? Mark for Review
(1) Points
OUT
IN (*)
COPY
DEFAULT
R(ead)
The parameter value passed into the subprogram is always returned unchan
ged to the calling environment.
The parameter value can be returned as the original unchanged value. (*)
The parameter value can be returned as a new value that is set within th
e procedure. (*)
Positional (*)
Named
Positional
Named
[Correct] Correct
OUT (*)
IN
CONSTANT
R(ead)
W(rite)
myproc(80, 'Smith');
NULL
1000 (*)
The procedure will not compile because P_SALARY should have been coded a
s DEFAULT 1000
The procedure does not execute because the input variable is not properl
y declared.
numproc(10,,20);
numproc(x=10,z=20);
numproc(10,z=>20); (*)
numproc(x=>10,20);
True
False (*)
[Correct] Correct
v_name := get_country_name(100);
DBMS_OUTPUT.PUT_LINE(get_country_name(100));
[Correct] Correct
find_sal(100,v_mynum);
v_mydate := find_sal(100);
find_sal(v_mynum,100);
[Incorrect] Incorrect. Refer to Section 9 Lesson 1.
DBMS_OUTPUT.PUT_LINE(get_job(100));
get_job(100,v_job_id); (*)
v_job_id := get_job(100);
MYPROC1 will compile and execute successfully, except that the call to M
YFUNC1 will be treated as a comment and ignored.
An exception section
IN parameters
Local variables in the IS/AS section
[Correct] Correct
p1 can have as many IN parameters as needed but f1 cannot have more than
two IN parameters.
Declare
Ann_comp number (6,2);
Begin
...
Ann_comp := annual_comp(1000,.2);
...
End;
B,E,F,D,A,C (*)
D,B,E,F,A,C
B,C,E,F,D,A
A,B,E,F,D,C
[Correct] Correct
True
False (*)
[Correct] Correct
True
False (*)
They can add business rules to the database and can be reused many times
.
They can do the same job as built-in system functions such as UPPER and
ROUND. (*)
True (*)
False
[Correct] Correct
[Correct] Correct
SELECT upd_dept(department_id)
FROM employees;
SELECT upd_dept(80)
FROM dual;
[Correct] Correct
RETURN BOOLEAN
Onqters (*)
An OUT parameter
COMMIT;
1. Which of the following best describes the Data Dictionary? Mark for
Review
(1) Points
It is a set of tables which can be updated by any user who has the neces
sary privileges.
[Correct] Correct
It allows the PL/SQL compiler to check for object existence; for example
, when creating a procedure which references a table, the PL/SQL compiler can ch
eck that the table exists.
USER_TABLES
ALL_TABLES (*)
DBA_TABLES
USER_TAB_COLUMNS
fn_index
FN_INDEX
fn_index FN_INDEX
SELECT COUNT(*)
FROM user_objects;
SELECT object_type, COUNT(*)
FROM user_objects
GROUP BY object_type;
(*)
DESCRIBE user_objects
GROUP BY object_type;
We can use it like a Web search engine to remind ourselves of the names
of dictionary views.
[Correct] Correct
An exception occurred
(*)
[Correct] Correct
99 only (*)
99 and 999
999 only
user_source (*)
user_procedures
user_objects
user_dependencies
user_errors
user_source
user_procedures
user_objects (*)
The user who executes the procedure needs EXECUTE privilege on the proce
dure. (*)
The user who executes the procedure does not need any privileges.
The user who executes the procedure needs SELECT privilege on EMPLOYEES.
(*)
[Correct] Correct
The procedure will fail because Curly does not have SELECT privilege on
NEWEMP.
The procedure will fail because there is no NEWEMP table in Curly's sche
ma. (*)
The procedure will fail because Curly does not have the EXECUTE ANY PROC
EDURE system privilege.
4. Users SYS (the DBA), TOM, DICK, and HARRY each have an E
MPLOYEES table in their schemas. SYS creates a procedure DICK.SEL_EMP using Invo
ker's Rights which contains the following code:
SELECT ... FROM EMPLOYEES ... ;
HARRY now executes the procedure. Which employees table will be queried?
Mark for Review
(1) Points
SYS.EMPLOYEES
DICK.EMPLOYEES
HARRY.EMPLOYEES (*)
True
False (*)
[Correct] Correct
True
False (*)
[Correct] Correct
SELECT on EMPLOYEES
CREATE on EMPLOYEES
DELETE on FRED.DEPARTMENTS
2 (*)
[Correct] Correct
user_dependencies
user_subprograms
procedures
variables
PL/SQL types
Exceptions
Related subprograms and variables can be grouped together for easier man
agement and maintenance.
[Correct] Correct
Body (*)
Specification
True (*)
False
Body
Specification
[Correct] Correct
True
False (*)
[Correct] Correct
BEGIN
dept_pack.ins_dept(20);
END;
(*)
BEGIN
dept_pack.get_dept(20);
END;
DECLARE
v_deptname VARCHAR2(20);
BEGIN
v_deptname := get_dept(50);
END;
BEGIN
dept_pack(30);
END;
DESCRIBE del_emp
DESCRIBE show_emp
DESCRIBE emp_pack
(*)
DESCRIBE emp_pack.del_emp
DESCRIBE emp_pack.show_emp
True (*)
False
[Correct] Correct
True
False (*)
The package will not compile because you cannot declare variables in the
specification, only procedures and functions. .
SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE'
ORDER BY line;
SELECT source FROM user_packages WHERE name = 'EMP_PKG' AND type = 'PACK
AGE BODY' ORDER BY line;
SELECT text FROM all_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE'
ORDER BY line;
SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type = 'PACKAGE
BODY' ORDER BY line; (*)
[Correct] Correct
The parameters which must be used when invoking all packaged subprograms
in the user's schema
[Correct] Correct
True (*)
False
True
False (*)
[Correct] Correct
True
False (*)
[Incorrect] Incorrect. Refer to Section 10 Lesson 2.
emp_pkg.emp_sal(101);
scott.emp_pkg.emp_sal(101): (*)
emp_sal(101);
[Correct] Correct
Section 1
(Answer all questions in this section)
1. Which two of these functions could not be in the same pa
ckage? 1. FUNCTION get_emp (p1 DATE) RETURN VARCHAR2; 2. FUNCTION get_emp (p1 DA
TE, p2 NUMBER) RETURN VARCHAR2; 3. FUNCTION get_emp (p1 DATE, p2 NUMBER) RETURN
NUMBER; 4. FUNCTION get_emp (p1 NUMBER, p2 DATE) RETURN VARCHAR2; Mark for
Review
(1) Points
1 and 2
1 and 4
2 and 4
2 and 3 (*)
3 and 4
over_pack.do_work1('Smith',20);
over_pack.do_work2('Smith',20); (*)
over_pack.do_work1(p1=>'Smith',p2=>20); (*)
over_pack.do_work1(param1=>'Smith');
True (*)
False
True
False (*)
True (*)
False
[Correct] Correct
Procedures only
Functions only
True (*)
False
[Correct] Correct
11. How would you invoke the constant km_to_mile from the gl
obal_consts bodiless package at VARIABLE A?
SELECT trail_name, distance_in_km * VARIABLE A
FROM trails
WHERE park_name = 'YOSEMITE';
Mark for Review
(1) Points
km_to_mile.global_consts
km_to_mile (global_consts)
global_consts.km_to_mile (*)
global_consts (km_to_mile)
Can read or modify the table being changed by that DML statement
True (*)
False
[Correct] Correct
INDEX BY INTEGER
INDEX BY BINARY
INDEX ALL