10 free sample questions from a bank of 107, with the correct answers and explanations. No signup required — start practising right now.
1The STUDENTS table exists in your schema.
Examine the DECLARE section of a PL/SQL block: Which two blocks are valid?
BEGIN OPEN cursor3 FOR SELECT * FROM students; cursor1 :=cursor3; END;
BEGIN OPEN stcur; cursor1 :=stcur; END;
BEGIN OPEN cursor1 FOR SELECT * FROM students; stcur :=cursor1; END;
BEGIN OPEN stcur; cursor3 :=stcur; END;
BEGIN OPEN cursor1 FOR SELECT * FROM students; cursor2 :=cursor1;
Answer:
2Which codes executes successfully?
CREATE PACKAGE pkg AS TYPE rec_typ IS RECORD (price NUMBER, inc_pct NUMBER); PROCEDURE calc_price (price_rec IN OUT rec_typ); END pkg; / CREATE PACAKGE BODY pkg AS PROCEDURE calc_price (price_rec IN OUT rec_typ) AS BEGIN price_rec.price := price_rec.price + (price_rec.price * price_rec.inc_pct)/100; END calc_price; END pkg; / DECLARE 1_rec pkg. rec_typ; BEGIN 1_rec_price :=100; 1_rec.inc_pct :=50; EXECUTE IMMEDIATE BEGIN pkg. calc_price (:rec); END; USING IN OUT 1_rec; END;
CREATE PACKAGE pkg AS TYPE rec_typ IS RECORD (price NUMBER, inc_pct NUMBER); END pkg; / CREATE PROCEDURE calc_price (price_rec IN OUT pkg. rec_typ) AS BEGIN price_rec.price := price_rec.price + (price_rec.price * price_rec.inc_pct)/100; END / DECLARE 1_rec pkg.rec_typ; BEGIN EXECUTE IMMEDIATE BEGIN calc_price (:rec); END; USING IN OUT 1_rec (100, 50); END;
CREATE PACKAGE pkg AS TYPE rec_typ IS RECORD (price NUMBER, inc_pct NUMBER); END pkg; / CREATE PROCEDURE calc_price (price_rec IN OUT pkg. rec_typ) AS BEGIN price_rec.price := price_rec.price + (price_rec.price * price_rec.inc_pct)/100; END ; / DECLARE 1_rec pkg. rec_typ; BEGIN 1_rec_price :=100; 1_rec.inc_pct :=50; EXECUTE IMMEDIATE BEGIN calc_price (1_rec); END;; END;
DECLARE TYPE rec_typ IS RECORD (price NUMBER, inc_pct NUMBER); 1_rec rec-typ; PROCEDURE calc_price (price_rec IN OUT rec_typ) AS BEGIN price_rec.price := price-rec.price+ (price_rec.price * price_rec.inc_pct)/100; END; BEGIN 1_rec_price :=100; 1_rec.inc_pct :=50; EXECUTE IMMEDIATE BEGIN calc_price (:rec); END; USING IN OUT 1_rec;
Answer: A
3Examine this function header:
FUNCTION calc_new_sal (emp_id NUMBER) RETURN NUMBER;
You want to ensure that whenever this PL/SQL function is invoked with the same parameter value across active sessions, the result is not recomputed.
If a DML statement is modifying a table which this function depends upon, the function result must be recomputed at that point in time for all sessions calling this function.
Which two actions should you perform?
Ensure RESULT_CACHE_MAX_SIZE is greater than 0.
Enable the result cache by using DBMS_RESULT_CACHE.BYPASS (FALSE).
Add the deterministic clause to the function definition.
Add the RELIES_ON clause to the function definition.
Add the RESULT_CACHE clause to the function definition.
Answer:
4Examine this block: Which two will be correct after line 5?
va. LAST and va. LIMIT will return the same value.
va. LAST and va. COUNT will return the same value.
va. LIMIT and va. COUNT will return the same value.
va. LIMIT and va. NEXT (199) will return the same value.
va. LAST will return 200.
va. NEXT (199) will return NULL.
Answer:
5Examine this code: You want to display the contents of CREATE_LIST.
Which two lines need to be corrected in the PL/SQL block?
Line 2
Line 3
Line 5
Line 6
Line 7
Answer:
6Examine the following SQL statement:
ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=3;
What is the result of executing this statements?
The PL/SQL optimize level for some existing PL/SQL units will be changed as an immediate result.
The PL/SQL optimize level for subsequently complied PL/SQL units will be set to 3 and inlining will be enabled.
The PL/SQL optimize level for subsequently compiled PL/SQL units will be set to 3 and inlining will be disabled.
This statement will fail because PLSQL_OPTIMIZE_LEVEL can only be set at the system level,
Answer: C
7Which two statements describe actions developers can take to make their application less vulnerable to security attacks?
Include the AUTHID DEFINER clause in stored program units.
Do not concatenate unchecked user input into dynamically constructed SQL statements.
Switch from using DBMS_SQL to EXECUTE IMMEDIATE.
Include the AUTHID CURRENT_USER clause in stored program units.
Increase the amount of code that is accessible to users by default.
Answer:
8Examine this code: What is the correct statement to get the value of attribute ACCOUNT_MGR after the procedure has been executed?
SELECT USERENV (‘ACCOUNT_MGR’) FROM dual;
SELECT SYS_CONTEXT (‘USERENV’, ‘ACCOUNT_MGR’) FROM dual;
SELECT SYS_CONTEXT (‘ORDER_CTX’, ‘ACCOUNT_MGR’) FROM dual;
SELECT SYS_CONTEXT (‘ACCOUNT_MGR’, ‘ORDER_CTX’) FROM dual;
SELECT USERENV (‘ORDER_CTX’) FROM dual;
Answer: B
9Examine this code: Examine this DML statement executed in the SCOTT schema:
UPDATE emp SET comm = 1000 WHERE deptno= 20;
What is the outcome after executing this statement?
COMM is set to 1000 for all records in the EMP table where DEPTNO = 30.
The statement executes successfully but no rows are updated.
COMM is set to 1000 for all records in the EMP table where DEPTNO=20.
The statement fails with error ORA-28115: policy with check option violation.
Answer: D
10Identify the two correct scenarios where a function can be optimized using the function result cache feature.
A function which inserts multiple records into a DEPARTMENTS table as part of one-time data setup for an HR application.
A function which accesses multiple tables and calculates the commission to be given to a sales representative based on the number of products sold by that representative.
A function which deletes all the records from an EMPLOYEES_AUDIT table based on their LOG_DATE.
A function which updates the SALARY of all the employees in an EMPLOYEES table by a fixed percentage based on their DESIGNATION.
A function which calculates the factorial of a given number without accessing any table.