diff --git a/Modules/MIP_FILES.pck b/Modules/MIP_FILES.pck index 2341aff..a5ad117 100644 --- a/Modules/MIP_FILES.pck +++ b/Modules/MIP_FILES.pck @@ -22,13 +22,11 @@ function set_file_association(p_uri in varchar2, p_enqu_id in number, p_drwg_code in varchar2, p_doro_type in varchar2) return boolean; - + PROCEDURE export_table_to_csv(p_table IN VARCHAR2, p_column_headers IN VARCHAR2, p_delimiter IN VARCHAR2 DEFAULT ','); - - - function are_files_over_size_limit(p_enqu_id number,p_uri varchar2) return BOOLEAN; + end MIP_FILES; / @@ -41,16 +39,16 @@ create or replace package body MIP_FILES as */ function is_file_over_size_limit(p_uri varchar2) return boolean is l_file_size wwv_flow_files.doc_size%type; - + BEGIN - + SELECT doc_size INTO l_file_size FROM wwv_flow_files WHERE NAME = p_uri; - + RETURN(l_file_size > 3 * 1024 * 1024); - + end is_file_over_size_limit; /* FUNCTION are_files_over_size_limit @@ -62,7 +60,7 @@ create or replace package body MIP_FILES as function are_files_over_size_limit(p_enqu_id NUMBER) return boolean is l_total_size number; BEGIN - + SELECT SUM(doc_size) INTO l_total_size FROM documents d @@ -71,9 +69,9 @@ create or replace package body MIP_FILES as WHERE dr.enqu_id = p_enqu_id AND d.id = dr.docu_id AND d.uri = f.NAME; - + RETURN (nvl(l_total_size,0) > 10 * 1024 * 1024); - + end are_files_over_size_limit; /* FUNCTION delete_file @@ -97,13 +95,13 @@ create or replace package body MIP_FILES as INTO l_uri; CLOSE c_get_uri; --set up a deletion event for the document - insert into document_events(docu_id, dost_code,event_date,description,id) + insert into document_events(docu_id, dost_code,event_date,description,id) values (p_id, p_doc_status, sysdate, p_reason, doev_seq.NEXTVAL); - --delete the actual file from the database + --delete the actual file from the database delete wwv_flow_files where wwv_flow_files.name = l_uri; return true; end delete_file; @@ -116,11 +114,11 @@ create or replace package body MIP_FILES as function quote_file_exists(p_qute_id number) return boolean is l_file_exists number; CURSOR c_file_exists(cp_qute_id number) IS - select 1 + select 1 from wwv_flow_files where name=(select d.uri - from documents d, document_roles dr - where dr.qute_id = cp_qute_id and d.id = dr.docu_id); + from documents d, document_roles dr + where dr.qute_id = cp_qute_id and d.id = dr.docu_id); begin IF NOT c_file_exists%ISOPEN THEN OPEN c_file_exists(p_qute_id); @@ -131,7 +129,7 @@ create or replace package body MIP_FILES as if l_file_exists is not null and l_file_exists>0 then return true; else - return false; + return false; end if; end quote_file_exists; /* @@ -143,11 +141,11 @@ create or replace package body MIP_FILES as function drawing_file_exists(p_drwg_code varchar2) return boolean is l_file_exists number; CURSOR c_file_exists(cp_drwg_code varchar2) IS - select 1 + select 1 from wwv_flow_files where name=(select d.uri - from documents d, document_roles dr - where dr.drwg_code = cp_drwg_code and d.id = dr.docu_id); + from documents d, document_roles dr + where dr.drwg_code = cp_drwg_code and d.id = dr.docu_id); begin IF NOT c_file_exists%ISOPEN THEN OPEN c_file_exists(p_drwg_code); @@ -158,7 +156,7 @@ create or replace package body MIP_FILES as if l_file_exists is not null and l_file_exists>0 then return true; else - return false; + return false; end if; end drawing_file_exists; /* @@ -180,28 +178,28 @@ create or replace package body MIP_FILES as p_enqu_id in number, p_drwg_code in varchar2) return boolean is l_doc_id number; - + begin --reference it in the documents table insert into documents( uri, description, id, docu_type ) values (p_uri, p_description, docu_seq.NEXTVAL, - p_docu_type) + p_docu_type) returning id into l_doc_id; --set up a role for the document - update document_roles set docu_id = l_doc_id - where drwg_code = nvl(p_drwg_code,'') or qute_id = nvl(p_qute_id,0) or enqu_id = nvl(p_enqu_id,0); + update document_roles set docu_id = l_doc_id + where drwg_code = nvl(p_drwg_code,'') or qute_id = nvl(p_qute_id,0) or enqu_id = nvl(p_enqu_id,0); --set up an event for the document - insert into document_events(docu_id, dost_code,event_date,description,id) + insert into document_events(docu_id, dost_code,event_date,description,id) values (l_doc_id, 'AWAIT SCAN', sysdate, p_description, - doev_seq.NEXTVAL); + doev_seq.NEXTVAL); --if it works then return true return true; - end update_file_association; + end update_file_association; /* FUNCTION set_file_association - sets the association between a object within webmip to a file held in the @@ -231,10 +229,10 @@ create or replace package body MIP_FILES as values (p_uri, p_description, docu_seq.NEXTVAL, - p_docu_type) + p_docu_type) returning id into l_doc_id; --set up a role for the document - insert into document_roles(rt_code, start_date,description,qute_id,enqu_id,drwg_code,id,doro_type,docu_id) + insert into document_roles(rt_code, start_date,description,qute_id,enqu_id,drwg_code,id,doro_type,docu_id) values (p_rt_code, sysdate, p_description, @@ -243,18 +241,18 @@ create or replace package body MIP_FILES as p_drwg_code, doro_seq.NEXTVAL, p_doro_type, - l_doc_id); + l_doc_id); --set up an event for the document - insert into document_events(docu_id, dost_code,event_date,description,id) + insert into document_events(docu_id, dost_code,event_date,description,id) values (l_doc_id, 'AWAIT SCAN', sysdate, p_description, - doev_seq.NEXTVAL); + doev_seq.NEXTVAL); if (are_files_over_size_limit(p_enqu_id) or is_file_over_size_limit(p_uri)) and p_rt_code = 'ENQUIRY SUPPORTING DOC' and not p_enqu_id is null then l_success := delete_file(l_doc_id,'REMOVED SIZE','webMIP determined the file or files to be too big'); return false; - else + else --if it works then return true return true; end if;