diff --git a/Modules/MIP_FILES.pck b/Modules/MIP_FILES.pck index a153178..68395e4 100644 --- a/Modules/MIP_FILES.pck +++ b/Modules/MIP_FILES.pck @@ -5,6 +5,7 @@ create or replace package MIP_FILES is -- Purpose : Handle files for the webMIP system -- Public function and procedure declarations +function delete_file(p_id number) return boolean; function drawing_file_exists(p_drwg_code varchar2) return boolean; function update_file_association(p_uri in varchar2, p_description in varchar2, @@ -28,6 +29,30 @@ PROCEDURE export_table_to_csv(p_table IN VARCHAR2, end MIP_FILES; / create or replace package body MIP_FILES as + /* + FUNCTION delete_file + - takes the id of a file held in the documents table and deletes the associated document + - in the documents, document_roles and wwv_flow_files tables and view + %param p_id - the id of the file + */ + function delete_file(p_id number) return boolean is + l_uri documents.uri%type; + CURSOR c_get_uri(cp_id number) is + select uri + from documents + where id=cp_id; + begin + IF NOT c_get_uri%ISOPEN THEN + OPEN c_get_uri(p_id); + END IF; + FETCH c_get_uri + INTO l_uri; + CLOSE c_get_uri; + delete document_roles where document_roles.docu_id = p_id; + delete documents where documents.id = p_id; + delete wwv_flow_files where wwv_flow_files.name = l_uri; + return true; + end delete_file; /* FUNCTION drawing_file_exists - takes the drawing code and searches for associated file in APEX Application