Section 10-13 PLSQL
Section 10-13 PLSQL
Section 10-13 PLSQL
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;
Body (*)
Specification
procedures
variables
PL/SQL types
Exceptions
Correct
DESCRIBE del_emp
DESCRIBE show_emp
DESCRIBE emp_pack
(*)
DESCRIBE emp_pack.del_emp
DESCRIBE emp_pack.show_emp
None of the above
Correct
True
False (*)
Correct
Related subprograms and variables can be grouped together for easier man
agement and maintenance.
Body
Specification
True (*)
False
Correct
1. What will be displayed when a user executes the followin
g statement?
SELECT object_name FROM user_objects
WHERE object_type LIKE 'PACK%';
Mark for Review
(1) Points
The names of all package specifications and package bodies in the user's
schema (*)
The parameters which must be used when invoking all packaged subprograms
in the user's schema
emp_pkg.emp_sal(101);
scott.emp_pkg.emp_sal(101): (*)
emp_sal(101);
True (*)
False
Correct
False (*)
Correct
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; (*)
True
False (*)
Correct
True
False (*)
Correct
True (*)
False
Correct
1. The package name must be included when calling a package
function from a SELECT statement executed outside the package. True or False?
Mark for Review
(1) Points
True (*)
False
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 (*)
km_to_mile.global_consts
km_to_mile (global_consts)
global_consts.km_to_mile (*)
global_consts (km_to_mile)
True (*)
False
Correct
True (*)
False
Correct
Procedures only
Functions only
True (*)
False
Correct
INDEX BY INTEGER
INDEX BY BINARY
INDEX ALL
Can read or modify the table being changed by that DML statement
1 and 2
1 and 4
2 and 4
2 and 3 (*)
3 and 4
curs_pkg.emp_curs%ISOPEN;
curs_pkg.close_curs;
curs_pkg.open_curs; (*)
EXIT WHEN curs_pkg.emp_curs%NOTFOUND;
True (*)
False
Correct
True
False (*)
10
50 (*)
25
Correct
1. Which DBMS_OUTPUT package subprogram places text into th
e buffer at Line 1?
IF v_bool1 AND NOT v_bool2 AND v_number < 25
THEN
--Line 1
ELSE
...
END IF;
DBMS_OUTPUT.NEW_LINE;
Mark for Review
(1) Points
Correct
INVALID_PATH (*)
NO_DATA_FOUND
WRITE_ERROR (*)
INVALID_OPERATION (*)
ZERO_DIVIDE
True
False (*)
Correct
TOO_MANY_ROWS
VALUE_ERROR (*)
ZERO_DIVIDE
NO_DATA_FOUND (*)
Correct
6. The DBMS_OUTPUT gives programmers an easy-to-use interf
ace to see for instance the current value of a loop counter or if a program make
s it to a particular branch of an IF statement. (True or False?) Mark for
Review
(1) Points
True (*)
False
Correct
7.
Mark for Review
(1) Points
(Choose all correct answers)
It is used to read and write text files stored outside the database. (*)
It is used to find out how much free space is left on an operating syste
m disk.
The procedure will not compile successfully because you cannot ALTER fun
ctions using Dynamic SQL.
The procedure will not compile successfully because the syntax of the AL
TER FUNCTION statement is incorrect.
Correct
True (*)
False
Correct
Correct
True
False (*)
Correct
ALTER (*)
GRANT (*)
SAVEPOINT
UPDATE
DROP (*)
Oracle queries the Data Dictionary to make sure that the tables referenc
ed in the SQL statement exist. (*)
True
False (*)
Incorrect. Refer to Section 12 Lesson 1.
Because the invoking user may not have CREATE TABLE privilege
Because when the procedure is compiled, Oracle cannot check if the param
eter value passed into the procedure is a valid column datatype (*)
Position A
Position B (*)
Position C
Position D
Correct
Return more readily any exceptions that are raised by the statement.
True (*)
False
Correct
Position A
Position B (*)
Position C
Correct
False
Correct
True
False (*)
Correct
Position A
Position B (*)
Position C
Correct
True
False (*)
True
False (*)
Correct
2. Which of the following are NOT allowed within a databas
e trigger? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)
COMMIT (*)
INSERT
A Boolean variable
SAVEPOINT (*)
True
False (*)
Correct
True (*)
False
Correct
False
Correct
Keeping a log of how many rows have been inserted into a table
You click your mouse on a button to choose the correct answer to this qu
estion (*)
mypack.packproc;
mytrigg; (*)
myproc;
v_number := myfunc;
True (*)
False
It should be an AFTER trigger because the Oracle Server cannot fire the
trigger until it knows that the employee has been deleted.
Correct
BEFORE (*)
INSTEAD
WHENEVER
INSTEAD OF (*)
AFTER (*)
A DML trigger cannot itself contain a DML statement such as INSERT INTO
audit_table
You cannot use COMMIT inside a trigger. (*)
Six times, once after each row and once at the end of the statement
Correct
None, the transactions are rolled back because the update failed. (*)
One
Three
Four
One
Two (*)
Three
Six
Eight
Correct
1. A row trigger has been created which is fired by UPDATE
ON employees. A user now executes a single SQL statement which updates four row
s of the EMPLOYEES table. How many times will the row trigger fire? Mark for
Review
(1) Points
Once
Twice
Five times
Eight times
True
False (*)
IF UPDATE('SALARY') THEN
IF UPDATING(SALARY) THEN
IF UPDATE(SALARY) THEN
They are special variables which must be DECLAREd within the trigger.
They allow the trigger code to see what data values are being inserted i
nto a row.
They are automatically declared boolean variables which allow the trigge
r body to detect which DML operation is being executed. (*)
(:OLD.employee_id, :OLD.job_id);
(:NEW.employee_id, :OLD.job_id);
(NEW.employee_id, NEW.job_id);
Correct
Before the triggering statement; Before each row; After each row; After
the triggering statement. (*)
Before the triggering statement; Before each row; After the triggering s
tatement.
Correct
1. You can create a trigger which prevents DDL statements
on an individual table, while still allowing DDL on other tables in the same sch
ema. True or False? Mark for Review
(1) Points
True
False (*)
Correct
When using CALL, only one DML statement can be tested, so UPDATE OR DELE
TE is wrong.
Correct
A DDL trigger
A DML trigger
A statement trigger
An INSTEAD OF trigger
The trigger body is reading the same table (employees) that the triggeri
ng event is updating. (*)
IF (SERVERERROR(942)) THEN
IF (IS_SERVERERROR(ORA-00942)) THEN
A table is dropped.
True
False (*)
True (*)
False
Correct
USER_SOURCE
USER_TRIGGER
USER_TRIGGERS (*)
USER_OBJECTS
None of the above, you cannot view the code of the trigger body after th
e trigger has been created.
Correct
DESCRIBE TRIGGER
True
False (*)
Correct