Reduce Number of Function Calls¶
Instead of using X_API.Get_Xxx
several times to fetch one value at a time, the X_API.Get
returns all public attributes in one call. Several function calls will quite obviously result in higher performance cost.
Examples¶
In the example below, the four methods of Activity_API
to retrieve individual attributes of a record could be replaced with one call to Activity_API.Get()
.
PROCEDURE Several_Gets (
activity_seq_ IN NUMBER,
contract_ IN VARCHAR2 )
IS
project_id_ VARCHAR2(10);
activity_site_exist_ VARCHAR2(10);
early_start_ DATE;
early_finish_ DATE;
activity_responsible_ VARCHAR2(30);
BEGIN
project_id_ := Activity_API.Get_Project_Id(activity_seq_);
activity_site_exist_ := Project_Site_API.Project_Site_Exist(project_id_, contract_);
early_start_ := Activity_API.Get_Early_Start(activity_seq_);
early_finish_ := Activity_API.Get_Early_Finish(activity_seq_);
activity_responsible_ := Activity_API.Get_Activity_Responsible(activity_seq_);
-- do something using single variables
END Several_Gets;
Replace the four calls with one Get
method.
PROCEDURE Single_Get (
activity_seq_ IN NUMBER,
contract_ IN VARCHAR2 )
IS
activity_rec_ Activity_API.Public_Rec;
activity_site_exist_ VARCHAR2(10);
BEGIN
activity_rec_ := Activity_API.Get(activity_seq_);
activity_site_exist_ := Project_Site_API.Project_Site_Exist(activity_rec_.project_id, contract_);
-- do something using activity_rec_
END Single_Get;