Monday, May 4, 2009

Create Function PL/Sql

Function returns a value to the caller.

As a procedure, a function has two parts: the specification and the body.

Implementation is placed in the body part.

The following statement creates the function get_app_rec. This is the body of the function.
  FUNCTION get_app_rec
  (p_app_no  IN  appointment.app_no%TYPE)
  RETURN appointment%ROWTYPE
   IS
      v_rec                  appointment%ROWTYPE;
   BEGIN
      SELECT *
        INTO v_rec
        FROM appointment
       WHERE app_no = p_app_no
      ;
      RETURN v_rec;
   END;

Spec of the function is :
   FUNCTION get_app_rec
      (p_app_no  IN  appointment.app_no%TYPE)
   RETURN appointment%ROWTYPE;

No comments:

Post a Comment