Borrado de documentos de la papelera
declare @FRM_ID varchar(20)
declare @QUERY varchar(1000)
SET @FRM_ID = 657;
--Permisos de lecutra
delete from SYS_READERS where DOC_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
--Properties
delete from SYS_PROPERTIES where SYS_PROPERTIES.OBJ_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
--Permisos
delete from SYS_ACC_DOC where DOC_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
--Adjuntos
delete from SYS_ATTACHMENTS where DOC_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
--Eventos Asincrnos trigger
delete from SYS_EVN_QUEUE where DOC_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
-- LOGS
delete from SYS_DOC_LOG where DOC_ID in (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID);
-- SYS_DOCUMENTS
delete from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID = @FRM_ID;
--Execute
SET @QUERY = 'delete from SYS_FIELDS_' + @FRM_ID + ' WHERE DOC_ID IN (select doc_id from SYS_DOCUMENTS where FLD_ID = 0 and FRM_ID ='+ @FRM_ID+ ')';
Exec (@QUERY)