137 lines
2.9 KiB
Transact-SQL
137 lines
2.9 KiB
Transact-SQL
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
-- disabilito triggers
|
|
DISABLE TRIGGER DatiCommessa.trg_DC_storicizza ON DatiCommessa;
|
|
DISABLE TRIGGER DatiCommForn.trg_DCF_storicizza ON DatiCommForn;
|
|
DISABLE TRIGGER DatiCommInteg.trg_DCI_storicizza ON DatiCommInteg;
|
|
DISABLE TRIGGER DatiFase.trg_DF_storicizza ON DatiFase;
|
|
GO
|
|
|
|
alter table DatiCommessa add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
alter table DatiCommForn add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
alter table DatiCommInteg add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
|
|
alter table DatiFase add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
alter table Storico_DatiCommessa add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
alter table Storico_DatiCommForn add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
alter table Storico_DatiCommInteg add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
alter table Storico_DatiFase add
|
|
modificatoDa nvarchar(250);
|
|
go
|
|
|
|
-- update tab principali
|
|
UPDATE DatiCommessa SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE DatiCommForn SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE DatiCommInteg SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE DatiFase SET modificatoDa = 'Maurizio Molteni'
|
|
GO
|
|
|
|
-- update tab storiche
|
|
UPDATE Storico_DatiCommessa SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE Storico_DatiCommForn SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE Storico_DatiCommInteg SET modificatoDa = 'Maurizio Molteni'
|
|
UPDATE Storico_DatiFase SET modificatoDa = 'Maurizio Molteni'
|
|
GO
|
|
|
|
-- riabilito i triggers
|
|
ENABLE TRIGGER DatiCommessa.trg_DC_storicizza ON DatiCommessa;
|
|
ENABLE TRIGGER DatiCommForn.trg_DCF_storicizza ON DatiCommForn;
|
|
ENABLE TRIGGER DatiCommInteg.trg_DCI_storicizza ON DatiCommInteg;
|
|
ENABLE TRIGGER DatiFase.trg_DF_storicizza ON DatiFase;
|
|
GO
|
|
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/**********************************************************
|
|
* STORED stp_ResComm_byIdxFase
|
|
*
|
|
* resoconto completo commessa da idxFase
|
|
*
|
|
* mod: S.E.L. 2013.09.04
|
|
*
|
|
**********************************************************/
|
|
create PROCEDURE stp_ResComm_byIdxFase
|
|
(
|
|
@idxFase INT
|
|
)
|
|
AS
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
|
;WITH myCTE AS
|
|
(
|
|
SELECT idxFaseAncest, SUM(BCWS_time) AS BCWSFasi_time, SUM(BCWS_money) AS BCWSFasi_money,
|
|
SUM(ACWP_time) AS ACWPFasi_time, SUM(ACWP_money) AS ACWPFasi_money
|
|
FROM ElencoFasiExpl
|
|
WHERE idxFaseAncest = @idxFase
|
|
GROUP BY idxFaseAncest
|
|
)
|
|
|
|
SELECT idxFase, AnnoCommessa, NumeroCommessa, nickname,
|
|
BCWS, BCWSFasi_money, BCWSFasi_time,
|
|
ACWPFasi_money, ACWPFasi_time,
|
|
ACWPFasi_money / CASE WHEN BCWSFasi_money > 0 THEN BCWSFasi_money ELSE ACWPFasi_money + 0.0001 END AS ratio_money,
|
|
ACWPFasi_time / CASE WHEN BCWSFasi_time > 0 THEN BCWSFasi_time ELSE ACWPFasi_time + 0.0001 END AS ratio_time
|
|
FROM DatiCommessa dc INNER JOIN myCTE cte ON dc.idxFase = cte.idxFaseAncest
|
|
WHERE idxFase = @idxFase
|
|
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(225, GETDATE())
|
|
GO
|
|
SELECT TOP 10 * FROM LogUpdateDb ORDER BY Versione DESC
|
|
GO
|