From 3dcf390ee94882a5a8271e3307134b74d3de4767 Mon Sep 17 00:00:00 2001 From: PriestJ Date: Tue, 8 Apr 2008 16:47:53 +0000 Subject: [PATCH] Fix for #442(SC1006) added a new function to return if the enquiry has quotes or not. Used by the delete quotes button on the enquiry form to hide the button if there are no quotes to delete. git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@4740 248e525c-4dfb-0310-94bc-949c084e9493 --- Modules/MIP_ENQUIRY.pck | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) 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 */