PL-SQL Practice 10-2
PL-SQL Practice 10-2
PL-SQL Practice 10-2
Local Variables
Global Variables
1. Create a package called hellofrom that contains three public procedures named
proc_1, proc_2
AS
PROCEDURE proc_1;
PROCEDURE proc_2;
PROCEDURE proc_3;
END hellofrom;
PROCEDURE proc_1
IS
BEGIN
proc_2;
END proc_1;
PROCEDURE proc_2
IS
BEGIN
proc_3;
END proc_2;
PROCEDURE proc_3
IS
BEGIN
END proc_3;
END hellofrom;
Also, proc_1 should call proc_2 and proc_2 should call proc_3, so you need to include a
reference
You will be making changes to this package specification and body, so make sure you
save both
2. DESCRIBE the package to check that all three procedures are visible. Then, create
and execute an
anonymous block which displays all three messages with only one procedure call.
DESC hellofrom;
Begin
hellofrom.proc_1;
End;
Modify the hellofrom package specification (not the body) so that only proc_1 is public
and proc_2 and
proc_3 are private. Recreate the package and then DESCRIBE it. What do you see?
AS
PROCEDURE proc_1;
END hellofrom;
3. What will happen if you try to run hellofrom.proc_1 now, before you make any
changes to the
body?
Try it.
"US_B902_PLSQL_S07.HELLOFROM"
4. What changes can you make to the package body in order for proc_1 to run
successfully? Make
procedure proc_2;
procedure proc_3;
PROCEDURE proc_1
IS
BEGIN
proc_2;
END proc_1;
PROCEDURE proc_2
IS
BEGIN
proc_3;
END proc_2;
PROCEDURE proc_3
IS
BEGIN
END proc_3;
END hellofrom;
5. Try to call each of the three procedures from anonymous blocks. What happens?
Explain why
1. begin
2. hellofrom.proc_2;
3. end;
The reason this happens is because the proc_2 and proc_3 procedures are private and
cannot be
8. Make sure you have saved the hellofrom package body code from question 1. Then
try to drop just
the body. What happens? What do you see when you DESCRIBE helloform?
Desc hellofrom;