0% found this document useful (0 votes)
182 views7 pages

Real Questions

This document contains 26 multiple choice questions about Oracle PL/SQL triggers, functions, procedures, and packages. Some key points covered include: - Triggers can fire before or after DML statements like INSERT, UPDATE, DELETE. - Functions must be stored in the database to be callable from SQL expressions. - Packages allow grouping of related objects and information hiding. - Stored procedures are named PL/SQL blocks that can accept parameters. - The USER_DEPENDENCIES dictionary view tracks object dependencies.

Uploaded by

virybatten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views7 pages

Real Questions

This document contains 26 multiple choice questions about Oracle PL/SQL triggers, functions, procedures, and packages. Some key points covered include: - Triggers can fire before or after DML statements like INSERT, UPDATE, DELETE. - Functions must be stored in the database to be callable from SQL expressions. - Packages allow grouping of related objects and information hiding. - Stored procedures are named PL/SQL blocks that can accept parameters. - The USER_DEPENDENCIES dictionary view tracks object dependencies.

Uploaded by

virybatten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Q1: Examine this function: CREATE OR REPLACE FUNCTIONCALC_PLAYER_

AVG(V_ ID inPLAYER_BAT_STAT.PLAYER_ID% TYPE) RETURN NUMBER ISV_


AVG NUMBER; BEGIN SELECT HITS /AT_ BATS INTOV_ AVG
FROMPLAYER_BAT_ STAT WHEREPLAYER_ ID =V_ ID; RETURN(V_ AVG); END ;
Which statement will successfully invoke this function in SQL* Plus?
A. SELECTCALC_PLAYER_AVG(PLAYER_ ID) FROMPLAYER_BAT_ STAT;
B. EXECUTECALC_PLAYER_AVG( 31);
C.CALC_PLAYER( RUTH);
D.CALC_PLAYER_AVG( 31);
E. STARTCALC_PLAYER_AVG( 31)
Answer: A
Q2-Which two statements about packages are true?( Choose two)
A. Packages can be nested.
B. You can pass parameters to packages.
C. A package is loaded into memory each time it is invoked.
D. The contents of packages can be shared by many applications.
E. You can achieve information hiding by making package constructs private.
Answer: D, E
Q3-Which two programming constructs can be grouped within a package?
( Choose two)
A. Cursor
B. Constant
C. Trigger
D. Sequence
E. View
F. Answer: A, B
Q4-Which statement is valid when removing procedures?
A. Use a drop procedure statement to drop a standalone procedure.
B. . Use a drop procedure statement to drop a procedure that is part of a package. Then
recompile the package specification.
C. Use a drop procedure statement to drop a procedure that is part of a package. Then
recompile the package body.
D. For faster removal and re- creation, do not use a drop procedure statement.
Instead, recompile the procedure using the alter procedure statement with the
REUSE SETTINGS clause.
Answer: A
Q5-You make a change to the body of the BB_ PACK package. The BB_ PACK body is
recompiled. What happens if the stand alone procedure VALIDATE_PLAYER_ STAT
references this package?
A. VALIDATE_PLAYER_ STAT cannot recompile and must be recreate
B. VALIDATE_PLAYER_ STAT is not invalidated.
C. .VALDIATE_PLAYER_ STAT is invalidated.
D. VALIDATE_PLAYER_ STAT and BB_ PACK are invalidated.
Answer: B
Q6-Which statements are true?( Choose all that apply)

A. If errors occur during the compilation of a trigger, the trigger is still created.
B. If errors occur during the compilation of a trigger you can go into SQL* Plus and
query theUSER_ TRIGGERS data dictionary view to see the compilation errors.
C. If errors occur during the compilation of a trigger you can use the SHOW ERRORS
command within iSQL* Plus to see the compilation errors.
D. If errors occur during the compilation of a trigger you can go into SQL *Plus and
query theUSER_ ERRORS data dictionary view to see compilation errors. Answer:
A, C, D
Q7-Which two dictionary views track dependencies?( Choose two)
A. USER_ SOURCE
B. UTL_ DEPTREE
C. USER_ OBJECTS
D. DEPTREE_ TEMPTAB
E. USER_ DEPENDENCIES
F. DBA_DEPENDENT_ OBJECTS
Answer: D, E
Q8-CREATE OR REPLACE FUNCTION calctax( sal NUMBER) RETURN NUMBER
IS BEGIN RETURN( sal * 0.05); END; If you want to run the above function from the
SQL* Plus prompt, which statement is true?
A. You need to execute the commandCALCTAX( 1000);.
B. You need to execute the command EXECUTE FUNCTION calctax;.
C. You need to create a SQL* Plus environment variable X and issue the command:
X :=CALCTAX( 1000);.
D. . You need to create a SQL* Plus environment variable X and issue the command
EXECUTE: X := CALCTAX;
E. You need to create a SQL* Plus environment variable X and issue the command
EXECUTE: X :=CALCTAX( 1000);
Answer: E
Q9-What part of a database trigger determines the number of times the trigger body
executes?
A. Trigger type
B. B. Trigger body
C. C. Trigger event
D. D. Trigger timing
Answer: A
Q10-When creating a function in SQL* Plus, you receive this message: Warning:
Function created with compilation errors.
Which command can you issue to see the actual error message?
A. SHOWFUNCTION_ ERROR
B. SHOWUSER_ ERRORS
C. SHOW ERRORS
D. SHOWALL_ ERRORS
Answer: C

Q11-Which statement about triggers is true?


A. You use an application trigger to fire when a DELETE statement occurs.
B. You use a database trigger to fire when an INSERT statement occurs.
C. You use a system event trigger to fire when an UPDATE statement occurs.
D. You use INSTEAD OF trigger to fire when a SELECT statement occurs. Answer: B
Q12- Which type of argument passes a value from a procedure to the calling
environment?
A. VARCHAR2
B. BOOLEAN
C. OUT
D. IN
Answer: C
Q13- You create a DML trigger. For the timing information, which is valid with a DML
trigger?
A. DURING
B. INSTEAD
C. ON SHUTDOWN
D. BEFORE
E. ON STATEMENT EXECUTION
Answer: d
Q14- You are about to change the arguments of theCALC_TEAM_ AVG function.
Which dictionary view can you query to determine the names of the procedures and
functions that invoke theCALC_TEAM_ AVG function?
A. USER_PROC_ DEPENDS
B. USER_ DEPENDENCIES
C. USER_ REFERENCES
D. USER_ SOURCE
Answer: B
Q15- A CALL statement inside the trigger body enables you to call ______.
A. A package.
B. A stored function.
C. A stored procedure.
D. Another database trigger.
Answer: C
Q16- You need to remove the database triggerBUSINESS_ HOUR.
Which command do you use to remove the trigger in the SQL* Plus environment?
A. DROP TRIGGERbusiness_ hour;
B. DELETE TRIGGERbusiness_ hour;
C. REMOVE TRIGGERbusiness_ hour;
D. ALTER TRIGGERbusiness_ hour REMOVE;
E. DELETE FROMUSER_ TRIGGERS WHERETRIGGER_ NAME =BUSINESS_
HOUR;
Answer: A

Q17- How can you migrate from a LONG to a LOB data type for a column?

A. Use theDBMS_MANAGE_LOB. MIGRATE procedure.


B. Use theUTL_MANAGE_LOB. MIGRATE procedure.
C. Use theDBMS_LOB. MIGRATE procedure.
D. Use the ALTER TABLE command. E. You cannot migrate from a LONG to a LOB
date type for a column.
Answer: D
Q18- Examine this procedure: CREATE OR REPLACE PROCEDUREINSERT_
TEAM(V_ ID in NUMBER,V_ CITY in VARCHAR2 DEFAULT AUSTIN,V_ NAME
in VARCHAR2) IS BEGIN INSERT INTO TEAM( id, city, name) VALUES(v_ id,v_
city,v_ name); COMMIT; END Which two statements will successfully invoke this
procedure in SQL* Plus?( Choose two)
A. EXECUTEINSERT_ TEAM;
B. EXECUTEINSERT_TEAM( 3,V_NAME=> LONGHORNS,V_CITY=>
AUSTIN);
C. EXECUTEINSERT_TEAM( 3,AUSTIN, LONGHORNS);
D. EXECUTEINSERT_ TEAM(V_ ID :=V_ NAME := LONGHORNS,V_
CITY := AUSTIN);
E. EXECUTEINSERT_ TEAM( 3, LONGHORNS);
Answer: B, C
Q19- To be callable from a SQL expression, auser- defined function must do what? A.
Be stored only in the database.
B. Have both IN and OUT parameters.
C. Use the positional notation for parameters.
D-turn a BOOLEAN or VARCHAR2 data type.
Answer: A
________________________________________________________________________
Q 20- Which two describe a stored procedure?( Choose two)
A. stored procedure is typically written in SQL.
B. A stored procedure is a named L/ SQL block that can accept parameters.
C. stored procedure is a type of L/ SQL subprogram that performs an action. D. stored
procedure has three parts: the specification, the body, and the exception handler part.
F. The executable section of a stored procedure contains statements that assigns values,
control execution, and return values to the calling environment.
Answer: B,C
Q21- What can you do with theDBMS_ LOB package?
A. Use theDBMS_LOB. WRITE procedure to write data to a BFILE.
B. . Use theDBMS_LOB. BFILENAME function to locate an external BFILE.
C. . Use theDBMS_LOB. FILEEXISTS function to find the location of a BFILE.
D. Use theDBMS_LOB. FILECLOSE procedure to close the file being accessed. Answer:
D

Q22- Examine this code: CREATE OR REPLACE PACKAGEcomm_ package ISg_


comm NUMBER := 10;
PROCEDUREreset_comm(p_ comm IN NUMBER); ENDcomm_ package; /

User Jones executes the following code at9: 01am: EXECUTEcomm_package.g_


comm := 15
User Smith executes the following code at9: 05am: EXECUTEcomm_paclage.g_
comm := 20
Which statement is true?
A.g _comm has a value of 15 at9: 06am for Smith.
B.g_ comm has a value of 15 at9: 06am for Jones.
C.g_ comm has a value of 20 at9: 06am for both Jones and Smith.
E. g_ comm hasa value of 15 at9: 03 am for both Jones and Smith.
F. g_ comm has a value of 10 at9:60 am for both Jones and Smith. F.g_ comm has a value
of 10 at9: 03am for both Jones and Smith
Answer: B
Q23- Examine this code: CREATE OR REPLACE FUNCTIONgen_email_
name(p_first_ name VARCHAR2,p_last_ name VARCHAR2,p_ id NUMBER)
RETURN VARCHAR2
ISv_email_ nameVARCHAR2( 19=;
BEGINv_email_ name :=SUBSTR(p_first_ name, 1, 1) ||SUBSTR(p_last_ name, 1, 7)
||@Oracle. com;
UPDATE employees SET email =v_email_ name
WHEREemployee_ id =p_ id; RETURNv_email_ name;
END
Which statement removes the function?
A. DROP en_email_ name;
B. REMOVEgen_email_ name;
C. . DELETEgen_email_ name;
D. DROP FUNCTION en_email_ name;
ANSWER :D
Q24- Examine this code: CREATE OR REPLACE PROCEDUREaudit_ action(p_
who VARCHAR2) AS BEGIN INSERT INTOaudit(schema_ user)VALUES(p_
who); ENDaudit_ action; / CREATE OR REPLACE TRIGGERwatch_ it AFTER
LOGON ON DATABASE CALLaudit_action(ora_login_ user);
What does this trigger do?
A. The trigger records an audit trail when a user makes changes to the database.
B. . The trigger marks the user as logged on to the database before an audit statement is
issued.
C. The trigger invoked the procedureaudit_ action each time a user logs on tohis/ her
schema and adds the username to the audit table.
D. The trigger invokes the procedureaudit_ action each time a user logs on to the
database and adds the username to the audit table.
Answer: D
Q25- Examine the trigger:
CREATE OR REPLACE TRIGGEREmp_ count AFTER DELETE
ONEmp_ tab FOR EACH ROW DELCARE n INTEGER;
BEGIN SELECT COUNT(*) INTO n FROMEmp_ tab;DMBS_OUTPUT.PUT_
LINE( There are now || a || employees,);

END;
This trigger results in an error after this SQL statement is entered:
DELETE FROMEmp_ tab WHERE Empno = 7499;
How do you correct the error?
A. Change the trigger type to a BEFORE DELETE.
B. Take out the COUNT function because it is not allowed in a trigger.
C. Remove theDBMS_ OUTPUT statement because it is not allowed in a trigger.
D. Change the trigger to astatement- level trigger by removing FOR EACH ROW.
Answer: D
Q26- Which two program declarations are correct for a stored program unit?( Choose
two)
A. CREATE OR REPLACE FUNCTIONtax_ amt(p_ id NUMBER) RETURN
NUMBER
B. CREATE OR REPLACE PROCEDUREtax_ amt(p_ id NUMBER) RETURN
NUMBER
C. CREATE OR REPLACE PROCEDUREtax_ amt(p _id NUMBER,p_ amount OUT
NUMBER)
D. CREATE OR REPLACE FUNCTIONtax_ amt(p_ id NUMBER)
RETURNNUMBER( 10,2)
E. CREATE OR REPLACE PROCEDUREtax_ amt(p_ id NUMBER,p_ amount
OUTNUMBER( 10, 2))
Answer: A, C
Q27- You need to implement a virtual private database( vpd). In order to have the
vpd functionality, a trigger is required to fire when every user initiates a session in
the database. What type of trigger needs to be created?
A. DML trigger
B. System event trigger
C. INSTEAD OF trigger
D. Application trigger
Answer: B
Q28- You need to disable all triggers on the EMPLOYEES table. Which command
accomplishes this?
A. None of these commands; you cannot disable multiple triggers on a table in
one command.
B. ALTER TRIGGERS ON TABLE employees DISABLE;
C. ALTER employees DISABLE ALL TRIGGERS;
D. ALTER TABLE employees DISABLE ALL TRIGGERS;
Answer: D
NOTE : THIS QUESTION CAME BY OCNTRARY MEANING ENABLE ALL
TRIGGERS AND NOT DISABLING THEM
Q29- Examine this code: CREATE OR REPLACE FUNCTIONcalc_ sal(p_ salary
NUMBER) RETURN NUMBER ISv_ raiseNUMBER( 4,2) DEFAULT 1.08; BEGIN
RETURNv_ raise *p_ salary; ENDcalc_ sal; /
Which statement accurately call the stored functionCALC_ SAL?( Choose two)
A. UPDATE employees(calc_sal( salary)) SET salary = salary *calc_sal( salary);
B. . INSERTcalc_sal( salary) NOT employees WHEREdepartment_ id = 60;

C. DELETE FROMemployees(calc_sal( salary)) WHEREcalc_sal( salary) > 1000;


D. . SELECT salary,calc_sal( salary) FROM employees WHEREdepartment_ id = 60;
E. . SELECTlast_ name, salary,calc_sal( salary) FROM employees ORDER
BYcalc_sal( salary);
Answer: D, E
Q30- CREATE OR REPLACE PACKAGEmetric_ converter ISc_ height
CONSTRAINT NUMBER := 2.54;c_ weight CONSTRAINT NUMBER := .454;
FUNCTIONcalc_ height(p_height_in_ inches NUMBER) RETURN NUMBER;
FUNCTIONcalc_ weight(p_weight_in_ pounds NUMBER) RETURN NUMBER; END;
/ CREATE OR REPLACE PACKAGE BODYmetric_ converter IS FUNCTIONcalc_
height(p_height_in_ inches NUMBER) RETURN NUMBER IS BEGIN
RETURNp_height_in_ inches *c_ height; ENDcalc_ height; FUNCTIONcalc_
weight(p_weight_in_ pounds NUMBER) RETURN NUMBER IS BEGIN
RETURNp_weight_in_ pounds *c_ weight ENDcalc_ weight ENDmetric_ converter; /
CREATE OR REPLACE FUNCTIONcalc_ height(p_height_in_ inches NUMBER)
RETURN NUMBER IS
BEGIN RETURNp_height_in_ inches *metric_converter.c_ height; ENDcalc_ height; /
Which statement is true?
A. If you remove the package specification, then the package body and the stand alone
stored functionCALC_ HEIGHT are removed.
B. B. If you remove the package body, then the package specification and the stand alone
stored functionCALC_ HEIGHT are removed.
C. If you remove the package specification, then the package body is removed.
D. If you remove the package body, then the package specification is removed.
E. If you remove the stand alone stored functionCALC_ HEIGHT, then theMETRIC_
CONVERTER package body and the package specification are removed.
F. The stand alone functionCALC_ HEIGHT cannot be created because its name is used in
a packaged function.
Answer: C
Q31- Local procedure A calls remote procedure B. Procedure B was compiled at 8A. M.
Procedure A was modified and recompiled at 9A. M. Remote procedure B was later
modified and recompiled at 11A. M. The dependency mode is set to TIMESTAMP.
What happens when procedure A is invoked at 1P. M?
A. There is no affect on procedure A and it runs successfully.
B. Procedure B is invalidated and recompiles when invoked.
C. Procedure A is invalidated and recompiles for the first time it is invoked.
D. . Procedure A is invalidated and recompiles for the second time it is invoked. Answer: D
with my best wishes with success
Hany Mahmoud Sanad
Software Eng, Beshara Group ,Kuwait.

You might also like