1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| USE [STORE]
GO
/****** Object: StoredProcedure [dbo].[SP_FILESVIEW] Script Date: 17/12/2023 05:26:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: JFC
-- Create date: 17/12/2023
-- Description: View files in each subfolders of a directory
-- =============================================
ALTER PROCEDURE [dbo].[SP_FILESVIEW]
-- Add the parameters for the stored procedure here
@DE_ID varchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @hasDocDet bit,
@hasDocDetDet bit;
-- Insert statements for procedure here
begin transaction;
begin try
truncate table DOCDET_TEMP;
truncate table DOCDETDET_TEMP;
truncate table FILESVIEW;
set @hasDocDet = (select count(*) from V_STOREDATAS where DE_ID = @DE_ID
and DD_ID is not null);
if @hasDocDet = 1
begin
insert into DOCDET_TEMP
select distinct DD_ID, DD_LIB
from V_STOREDATAS
where DE_ID = @DE_ID;
if @hasDocDetDet = 1
begin
insert into DOCDETDET_TEMP
select distinct DDD_ID, DDD_LIB
from V_STOREDATAS
where DE_ID = @DE_ID;
insert into FILESVIEW
select KD_ID, DETAILED_LIB, FULLPATH, DDD_ID
from V_STOREDATAS
where DE_ID = @DE_ID;
end
else
begin
insert into FILESVIEW
select KD_ID, DETAILED_LIB, FULLPATH, DD_ID
from V_STOREDATAS
where DE_ID = @DE_ID;
end
end
else
begin
insert into FILESVIEW
select KD_ID, DETAILED_LIB, FULLPATH, DD_ID
from V_STOREDATAS
where DE_ID = @DE_ID;
end
commit transaction;
end try
begin catch
rollback transaction;
end catch
END |
Partager