Lab 12.2 Exercise Answers


12.2.1 Answers

a)

Explain what is happening in the find_sname procedure. What parameters are being passed into and out of the procedure? How would you call the procedure?

A1:

Answer: The procedure takes in a student_id via the parameter named i_student_id . It passes out the parameters o_first_name and o_last_name . The procedure is a simple SELECT statement retrieving the first_name and last_name from the Student table where the student_id matches the value of the i_student_id , which is the only in parameter that exists in the procedure. To call the procedure, a value must be passed in for the i_student_id parameter.


b)

Explain the relationship between the parameters that are in the procedures header definition versus the parameters that are passed IN and OUT of the procedure.

A1:

Answer: When calling the procedure find_sname, a valid student_id should be passed in for the i_student_id . If it is not a valid student_id , the exception will be raised. Two variables must also be listed when calling the procedure. These variables , v_local_first_name and v_local_last_name , are used to hold the values of the parameters that are being passed out. After the procedure has been executed, the local variables will have value and can then be displayed with a DBMS_OUTPUT.PUT _LINE.




Oracle PL[s]SQL by Example
Oracle PL[s]SQL by Example
ISBN: 3642256902
EAN: N/A
Year: 2003
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net