diff --git a/Modules/MIP_FILES.pck b/Modules/MIP_FILES.pck index edfc10e..b6b9ec2 100644 --- a/Modules/MIP_FILES.pck +++ b/Modules/MIP_FILES.pck @@ -30,6 +30,68 @@ PROCEDURE export_table_to_csv(p_table IN VARCHAR2, end MIP_FILES; / create or replace package body MIP_FILES as + /* + FUNCTION is_file_over_size_limit + - takes the uri of the file to test for size and returns true if the file + - is over 3 meg (3145728 bytes) in size + %param p_uri - the uri of the file + */ + function is_file_over_size_limit(p_uri varchar2) return boolean is + l_file_size wwv_flow_files.doc_size%type; + CURSOR c_get_filesize(cp_uri varchar2) is + select doc_size + from wwv_flow_files + where name=cp_uri; + begin + IF NOT c_get_filesize%ISOPEN THEN + OPEN c_get_filesize(p_uri); + END IF; + FETCH c_get_filesize + INTO l_file_size; + CLOSE c_get_filesize; + if l_file_size > 3145728 then + return true; + else + return false; + end if; + end is_file_over_size_limit; + /* + FUNCTION are_files_over_size_limit + - takes the enquiry id and an additional uri of the file to test for size + - and returns true if all the current files and plus additional file pointed + - by the uri are over 10 meg (10485760 bytes) in size + %param p_uri - the uri of the file + %param p_enqu_id - id of the enquiry to check the files for + */ + function are_files_over_size_limit(p_enqu_id number,p_uri varchar2) return boolean is + l_count_size number; + l_file_size wwv_flow_files.doc_size%type; + CURSOR c_get_enquiry_files(cp_id number) is + select f.* + from documents d,DOCUMENT_ROLES dr ,wwv_flow_files f + where dr.enqu_id = cp_id and d.id = dr.docu_id and d.uri = f.name; + CURSOR c_get_filesize(cp_uri varchar2) is + select doc_size + from wwv_flow_files + where name=cp_uri; + + begin + IF NOT c_get_filesize%ISOPEN THEN + OPEN c_get_filesize(p_uri); + END IF; + FETCH c_get_filesize + INTO l_file_size; + CLOSE c_get_filesize; + l_count_size := 0; + FOR file_rec IN c_get_enquiry_files(p_enqu_id) LOOP + l_count_size := l_count_size + file_rec.doc_size; + end loop; + if l_count_size + l_file_size > 10485760 then + return true; + else + return false; + end if; + end are_files_over_size_limit; /* FUNCTION delete_file - takes the id of a file held in the documents table and deletes the associated document @@ -166,6 +228,10 @@ create or replace package body MIP_FILES as l_doc_id number; begin + if (are_files_over_size_limit(p_enqu_id,p_uri) or is_file_over_size_limit(p_uri)) and p_rt_code = 'ENQUIRY SUPPORTING DOC' and not p_enqu_id is null then + delete wwv_flow_files where wwv_flow_files.name = p_uri; + return false; + else --reference it in the documents table insert into documents( uri, description, id, docu_type ) values (p_uri, @@ -186,6 +252,7 @@ create or replace package body MIP_FILES as l_doc_id); --if it works then return true return true; + end if; end set_file_association; /* PROCEDURE export_data_to_csv