Professional Documents
Culture Documents
Explanation:
Subprograms allow you to create just one occurrence of a piece of code that must be
executed in different locations of a procedure.
Use subprograms when the code is only executed within the procedure. If the code is
executed from outside the procedure, then the subprogram should be written as a packaged
or stand-alone procedure instead.
PROCEDURE calc_comm
IS
v_total NUMBER;
BEGIN
SELECT SUM(ord.total)
INTO v_total
FROM ord,customer
WHERE ord.custid = customer.custid
AND customer.repid = v_emp_id;
v_comm := v_total * .20;
END calc_comm;
BEGIN
...
calc_comm;
...
calc_comm;
...
calc_comm;
END;
EXECUTE find_seats_sold;
RUN find_seats_sold (v_theater_id => 500, v_movie_id => 34);
EXECUTE find_seats_sold (v_theater_id => 500, v_movie_id => 34);
EXECUTE find_seats_sold (v_theater_id := 500, v_movie_id := 34);
Explanation:
You can specify argument values using the positional or named method. The named
method requires the use of the "=>" operator to specify a value for each argument.
The value of 500 is assigned to the first argument listed in the procedure header and 34 is
assigned to the second argument.
Explanation:
Subprograms allow you to create just one occurrence of a piece of code that must be
executed in different locations of a procedure.
Use local subprograms when the code is only executed within the procedure. If the code will
be executed from outside the procedure, then the subprogram should be written as a
packaged or stand-alone procedure instead.
PROCEDURE calc_comm
IS
v_total NUMBER;
BEGIN
SELECT SUM(ord.total)
INTO v_total
FROM ord,customer
WHERE ord.custid = customer.custid
AND customer.repid = v_emp_id;
v_comm := v_total * .20;
END calc_comm;
BEGIN
...
calc_comm;
...
calc_comm;
...
calc_comm;
END;
Which type of construct should you create to solely perform an action without
returning a value?
view
function
procedure
packaged function
Explanation:
Procedures are usually created to perform an action without returning a value. Procedures
can return a value using an OUT argument. Functions must return a value.
RUN find_seats_sold(34);
EXECUTE find_seats_sold;
EXECUTE find_seats_sold (34);
find_seats_sold ('Riverplace Theater');
Explanation:
Executing a procedure in SQL*Plus requires the EXECUTE command. This procedure has
one IN argument. Therefore, use this command:
When invoking a procedure, you can specify the arguments using the positional
method by listing the values in the order of the argument list. Which method
would you use to list values in an arbitrary order?
FIFO
list
type
named
Explanation:
You can specify argument values using the positional or named method. The named
method requires the use of the "=>" operator to specify a value for each argument and
allows for an arbitrary assignment of values.
The value of 500 is assigned to the first argument listed in the procedure header and 34 is
assigned to the second argument.