UPDATE TBDD_MODULES SET DB_VERSION = '1.1.0.2' WHERE SHORT_NAME = 'SIG_ENV_CR'
GO

CREATE PROCEDURE PRSIG_DELETE_ENVELOPE_FINALLY @ENVELOPEUID VARCHAR(100)
AS
DECLARE @ENV_GUID INT
SELECT @ENV_GUID = GUID FROM [DD_ECM].[dbo].[TBSIG_ENVELOPE] where ENVELOPE_UUID = @ENVELOPEUID;
DELETE FROM TBSIG_ENVELOPE_CERTIFICATE where ENVELOPE_ID = @ENV_GUID;
DELETE FROM TBSIG_ENVELOPE_DOCUMENT where ENVELOPE_ID = @ENV_GUID;
DELETE FROM TBSIG_ENVELOPE_HISTORY where ENVELOPE_ID = @ENV_GUID;
DELETE FROM TBSIG_ENVELOPE_RECEIVER where ENVELOPE_ID = @ENV_GUID;
DELETE FROM TBSIG_ENVELOPE where GUID = @ENV_GUID;
