You are on page 1of 10

SECTION 8

LESSON 1
1. PL/SQL subprograms, unlike anonymous blocks, are compiled each time they are executed. True or False
!ark "or #e$ie%
&1' Points
True
False &('
)ncorrect. #e"er to Section * Lesson 1.
+. The "ollo%ing are the steps in$ol$ed in creating, and later modi"ying and re,creating, a PL/SQL
procedure in -pplication .xpress. /hich step is missing
-. Type the procedure code in the SQL 0ommands %indo%
1. 0lick on the 2Sa$e2 button and sa$e the procedure code
0. #etrie$e the sa$ed code "rom 2Sa$ed SQL2 in SQL 0ommands
3. !odi"y the code in the SQL 0ommands %indo%
.. .xecute the code to re,create the procedure
!ark "or #e$ie%
&1' Points
.nter parameters and data type
.xecute the procedure "rom 4S.#5S64#0. data dictionary $ie%
.xecute the code to create the procedure &('
)n$oke the procedure "rom an anonymous block
0orrect
7. Procedures are generally used to per"orm %hat !ark "or #e$ie%
&1' Points
- S.L.0T statement
-n action &('
- return o" $alues
-ll o" the abo$e
8one o" the abo$e
0orrect
9. /hich o" the "ollo%ing are characteristics o" anonymous PL/SQL blocks but not PL/SQL
subprograms &0hoose three.' !ark "or #e$ie%
&1' Points &0hoose all correct ans%ers'
0an take parameters
-re stored in the database
0an begin %ith the key%ord 3.0L-#. &('
-re unnamed &('
-re compiled e$ery time they are executed &('
)ncorrect. #e"er to Section * Lesson 1.
:. Subprograms and anonymous blocks can be called by other applications. True or False !ark
"or #e$ie%
&1' Points
True
False &('
)ncorrect. #e"er to Section * Lesson 1.
;. - nested subprogram can be called "rom the main procedure or "rom the calling en$ironment. True
or False !ark "or #e$ie%
&1' Points
True
False &('
0orrect
<. /hich o" the "ollo%ing key%ords !4ST be included in e$ery PL/SQL procedure de"inition
&0hoose t%o.' !ark "or #e$ie%
&1' Points &0hoose all correct ans%ers'
1.=)8 &('
#.PL-0.
.>0.PT)68
3.0L-#.
.83 &('
0orrect
*. - programmer %ants to create a PL/SQL procedure named !?5P#60. /hat %ill happen %hen the
"ollo%ing code is executed
0#.-T. 6# #.PL-0. P#60.34#. my5proc )S
$5empid employees.empid@T?P.A
1.=)8
S.L.0T employee5id )8T6 $5empid F#6! employees
/B.#. region5id C DDDA
31!S564TP4T.P4T5L)8.&EThe salary isF E GG $5salary'A
!ark "or #e$ie%
&1' Points
The statement %ill raise a 8653-T-5F6483 exception because region5id DDD does not exist.
The statement %ill "ail because the last line o" code should be .83 emp5procA &('
The statement %ill "ail because you cannot declare $ariables such as $5empid inside a procedure.
)ncorrect. #e"er to Section * Lesson 1.
D. /hich o" the "ollo%ing are bene"its o" using PL/SQL subprograms rather than anonymous blocks
&0hoose three.' !ark "or #e$ie%
&1' Points &0hoose all correct ans%ers'
1etter data security &('
0ode reuse &('
Stored externally
.asier code maintenance &('
3o not need to de"ine exceptions
)ncorrect. #e"er to Section * Lesson 1.
1H. - stored PL/SQL procedure can be in$oked "rom %hich o" the "ollo%ing
-. - PL/SQL anonymous block
1. - calling application
0. - S.L.0T statement
3. -nother PL/SQL procedure
!ark "or #e$ie%
&1' Points
- only
- and 1
- and 0
-, 1 and 3 &('
1 and 0
)ncorrect. #e"er to Section * Lesson 1.
11. - stored procedure add5dept may be in$oked by the "ollo%ing command in -pplication .xpress.
True or False
1.=)8
add5deptA
.83A
!ark "or #e$ie%
&1' Points
True &('
False
)ncorrect. #e"er to Section * Lesson 1.
1+. /hen modi"ying procedure code, the procedure must be re,executed to $alidate and store it in the
database. True or False !ark "or #e$ie%
&1' Points
True &('
False
0orrect
17. /hy %ill the "ollo%ing procedure "ail
0#.-T. 6# #.PL-0. P#60.34#. mainproc
...
)S
P#60.34#. subproc &...' )S 1.=)8
...
1.=)8
...
subproc &...'A
...
.83A
!ark "or #e$ie%
&1' Points
Procedure main proc must use the key%ord -S not )S
Procedure mainproc does not need the key%ord 1.=)8
Procedure subproc does not need the key%ord 1.=)8
Procedure subproc does not ha$e an .83A statement &('
)ncorrect. #e"er to Section * Lesson 1.
LESSON 2
1. ?ou %ant to create a procedure %hich accepts a single parameter. The parameter is a number %ith a
maximum $alue o" DDDD.DD. /hich o" the "ollo%ing is a $alid declaration "or this parameter !ark "or
#e$ie%
&1' Points
&$5num 84!1.#&;,+''
&$5num 84!1.#' &('
&$5num'
&$5num 84!1.#&9,+''
0orrect
+. /hat is the correct syntax to create procedure !?P#60 that accepts t%o number parameters > and
? !ark "or #e$ie%
&1' Points
0#.-T. P#60.34#. myproc &x 84!1.#, y 84!1.#' )S ... &('
0#.-T. P#60.34#. &x 84!1.#, y 84!1.#' myproc )S ...
0#.-T. P#60.34#. myproc )S &x 84!1.#, y 84!1.#' ...
0#.-T. P#60.34#. )S myproc &x 84!1.#, y 84!1.#' ...
)ncorrect. #e"er to Section * Lesson +.
7. /hat is the purpose o" using parameters %ith stored procedures !ark "or #e$ie%
&1' Points
They pre$ent the procedure "rom modi"ying data in the database.
They allo% $alues to be passed bet%een the calling en$ironment and the procedure. &('
They count the number o" exceptions raised by the procedure.
They speed up the execution o" the procedure.
0orrect
9. Procedure T.STP#60 accepts one parameter P1, %hose $alue is up to 1HHH characters in length.
/hich one o" the "ollo%ing declares this parameter correctly !ark "or #e$ie%
&1' Points
0#.-T. P#60.34#. testproc
&p1 I-#0B-#+&1HH' '
)S
1.=)8 ....
0#.-T. P#60.34#. testproc
)S
p1 I-#0B-#+&1HH'A
1.=)8 ....
0#.-T. P#60.34#. testproc
3.0L-#.
p1 I-#0B-#+&1HH'A
1.=)8 ....
0#.-T. P#60.34#. testproc
p1 I-#0B-#+
)S
1.=)8 ....
0#.-T. P#60.34#. testproc
&p1 I-#0B-#+'
)S
1.=)8 ....
&('
)ncorrect. #e"er to Section * Lesson +.
:. Procedure S41P#60 %as created asF
0#.-T. P#60.34#. subproc
&p5param I-#0B-#+'
)S 1.=)8 ...
?ou in$oke the procedure byF
3.0L-#.
$5param I-#0B-#+&+H' FC ESmithEA
1.=)8
subproc&$5param'A
.83A
/hich o" the "ollo%ing is the actual parameter
!ark "or #e$ie%
&1' Points
p5param
$5param &('
ESmithE
8one o" the abo$e.
)ncorrect. #e"er to Section * Lesson +.
;. /hich o" the "ollo%ing best describes the di""erence bet%een a parameter and an argument
!ark "or #e$ie%
&1' Points
They are both names o" $ariables. - parameter is passed into the procedure, %hile an argument is passed
out o" the procedure
- parameter is the name o" a $ariable, %hile an argument is the datatype o" that $ariable
- parameter is the name o" a $ariable that is passed into or out o" a procedure, %hile an argument is the
$alue o" that $ariable &('
There is no di""erence, parameters and arguments are the same thing
0orrect
<. /hich one o" the "ollo%ing statements about "ormal and actual parameters is true !ark "or
#e$ie%
&1' Points
Formal and actual parameters must ha$e the same name.
Formal and actual parameters must ha$e di""erent names.
- "ormal parameter is declared %ithin the called procedure, %hile an actual parameter is declared in the
calling en$ironment. &('
-n actual parameter is declared %ithin the called procedure.
)ncorrect. #e"er to Section * Lesson +.
*. /hich o" the "ollo%ing can be used as an argument "or a procedure parameter !ark "or
#e$ie%
&1' Points
The name o" a $ariable.
- literal $alue.
-n expression.
-ll o" the abo$e. &('
8one o" the abo$e.
0orrect
D. - procedure has been created asF
0#.-T. P#60.34#. myproc
&p5le"t 84!1.#, p5right 84!1.#'
)S 1.=)8 ....
?ou %ant to call the procedure "rom an anonymous block. /hich o" the "ollo%ing calls is $alid
!ark "or #e$ie%
&1' Points
myproc&p5le"t, p5right'A
myproc&$5le"t, $5right'A
myproc&$5le"t, 7H'A
-ll o" the abo$e. &('
)ncorrect. #e"er to Section * Lesson +.
LESSON 3
1. - procedure is in$oked by this commandF
myproc&ESmithE,1HH,:HHH'A
/hat is the method o" passing parameters used here
!ark "or #e$ie%
&1' Points
Positional &('
8amed
- combination o" positional and named.
8one o" the abo$e
0orrect
+. )" you donEt speci"y a mode "or a parameter, %hat is the de"ault mode !ark "or #e$ie%
&1' Points
64T
)8 &('
06P?
3.F-4LT
#&ead'
0orrect
7. Procedure 84!P#60 has been created asF
0#.-T. P#60.34#. numproc
&x 84!1.#, y 84!1.# FC 1HH, J 84!1.#' )S 1.=)8 ....
?ou %ant to call the procedure, passing arguments o" 1H "or > and +H "or K. /hich one o" the "ollo%ing calls is
correct
!ark "or #e$ie%
&1' Points
numproc&1H,,+H'A
numproc&xC1H,JC+H'A
numproc&1H,JCL+H'A &('
numproc&xCL1H,+H'A
0orrect
9. - procedure is in$oked by this commandF
myproc&ESmithE,salaryCL:HHH'A
/hat is the method o" passing parameters used here
!ark "or #e$ie%
&1' Points
Positional
8amed
- combination o" positional and named &('
8one o" the abo$e
0orrect
:. Three )8 parameters "or procedure -335.!PL6?.. are de"ined asF
&p5name I-#0B-#+ ,
p5salary 84!1.# FC 1HHH,
p5hired 3-T. 3.F-4LT S?S3-T.'
The procedure is in$oked byF
add5employee&EMonesE'A
/hat is the $alue o" P5S-L-#? %hen the procedure starts to execute
!ark "or #e$ie%
&1' Points
84LL
1HHH &('
The procedure %ill not compile because P5S-L-#? should ha$e been coded as 3.F-4LT 1HHH
The call %ill "ail because P5S-L-#? is a reNuired parameter
0orrect
;. /hich kind o" parameters cannot ha$e a 3.F-4LT $alue !ark "or #e$ie%
&1' Points
64T &('
)8
068ST-8T
#&ead'
/&rite'
0orrect
<. /hich o" the "ollo%ing statements about )8 64T parameters is true &0hoose t%o.' !ark "or
#e$ie%
&1' Points &0hoose all correct ans%ers'
The data type "or the parameter must be I-#0B-#+.
The parameter $alue passed into the subprogram is al%ays returned unchanged to the calling en$ironment.
The parameter $alue can be returned as the original unchanged $alue. &('
The parameter $alue can be returned as a ne% $alue that is set %ithin the procedure. &('
0orrect
*. /hat are the three parameter modes "or procedures !ark "or #e$ie%
&1' Points
)8, 64T, )8 64T &('
#&ead', /&rite', -&ppend'
068ST-8T, I-#)-1L., 3.F-4LT
06P?, 8606P?, #.F
0orrect
D. /hen creating a procedure, %here in the code must the parameters be listed !ark "or #e$ie%
&1' Points
-"ter the procedure name. &('
-"ter the key%ord )S or -S.
1e"ore the procedure name.
-"ter the key%ord P#60.34#..
0orrect
1H. The "ollo%ing procedure has been createdF
0#.-T. 6# #.PL-0. P#60.34#. myproc
&p5p1 84!1.#, p5p+ I-#0B-#+'
)S 1.=)8 ...
/hich one o" the "ollo%ing calls to the procedure %ill 86T %ork
!ark "or #e$ie%
&1' Points
myproc&*H, ESmithE'A
myproc&p5p1 CL *H, ESmithE'A &('
myproc&*H, p5p+ CL ESmithE'A
myproc&p5p1 CL *H, p5p+ CL ESmithE'A
0orrect
11. /hat %ill happen %hen the "ollo%ing procedure is called as "ormat5phone &*HH:::1+79'
0#.-T. 6# #.PL-0. P#60.34#. "ormat5phone
&p5phone5no )8 64T I-#0B-#+' )S
1.=)8
p5phone5no FC S41ST#&p5phone5no,1,7' GG
E.E GG S41ST#&p5phone5no,9,7' GG
E.E GG S41ST#&p5phone5no,<'A
.83 "ormat5phoneA
!ark "or #e$ie%
&1' Points
The phone number *HH.:::.1+79 is printed to the screen.
The phone number &*HH' :::,1+79 is printed to the screen.
The phone number *HH.:::.1+79 is placed into the p5phone5no $ariable. &('
The procedure does not execute because the input $ariable is not properly declared.
)ncorrect. #e"er to Section * Lesson 7.

You might also like