diff --git a/Modules/MIP_ENQUIRY.pck b/Modules/MIP_ENQUIRY.pck index 47b320e..f6a31c6 100644 --- a/Modules/MIP_ENQUIRY.pck +++ b/Modules/MIP_ENQUIRY.pck @@ -15,6 +15,8 @@ CREATE OR REPLACE PACKAGE mip_enquiry IS ,required_mesc_code meters.mesc_code%TYPE); -- Public function and procedure declarations + FUNCTION enquiry_has_quotes(p_enquiryid IN NUMBER) RETURN BOOLEAN; + FUNCTION can_enquiry_be_deleted(p_enquiryid IN NUMBER) RETURN BOOLEAN; FUNCTION get_enquiry_status(p_enquiryid IN NUMBER) RETURN VARCHAR2; @@ -106,11 +108,37 @@ CREATE OR REPLACE PACKAGE BODY mip_enquiry IS ,p_in => p_in); /* $END*/ END pl; - + /* + FUNCTION enquiry_has_quotes + - This function returns true if the enquiry has quotes + %param p_enquiryid - the enquiry we want to find quotes from. + %return boolean - true if the enquiry has quotes + */ + FUNCTION enquiry_has_quotes(p_enquiryid IN NUMBER) RETURN BOOLEAN AS + -- cursor to get the current enquiry + CURSOR c_count_all_quotes(cp_enqu_id NUMBER) IS + SELECT COUNT(id) + FROM quotes + WHERE enqu_id = cp_enqu_id; + l_quotes_num NUMBER := 0; + BEGIN + IF NOT c_count_all_quotes%ISOPEN THEN + OPEN c_count_all_quotes(p_enquiryid); + END IF; + + FETCH c_count_all_quotes + INTO l_quotes_num; + CLOSE c_count_all_quotes; + IF l_quotes_num > 0 THEN + RETURN TRUE; + ELSE + RETURN FALSE; + END IF; + END enquiry_has_quotes; /* FUNCTION can_enquiry_be_deleted - - This function returns the status of the enquiry provided - - and associated quotes to see if it can be deleted + - This function returns the status of the enquiry's + - associated quotes to see if it can be deleted %param p_enquiryid - the enquiry we want to find the role from. %return boolean - true if the enquiry can be deleted */