88 lines
1.9 KiB
Transact-SQL
88 lines
1.9 KiB
Transact-SQL
/* modifiche per gestione corretta reportistica x mtz preventiva o meno... */
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
alter table InterventiMtz add
|
|
scheduled bit constraint DF_InterventiMtz_scheduled default (0)
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_Description', 'indica se l''intervento sia stato generato da manutenzione programmata/preventiva', 'USER', 'dbo', 'TABLE', 'InterventiMtz', 'COLUMN', 'scheduled'
|
|
go
|
|
|
|
update InterventiMtz set scheduled=0
|
|
go
|
|
|
|
commit
|
|
go
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set ANSI_NULLS on
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE sp_insRichiesta
|
|
* Inserisce nuova richiesta di intervento
|
|
*
|
|
* modif.: S.E.L. - 2009.02.20
|
|
**************************************/
|
|
alter PROCEDURE sp_insRichiesta
|
|
(
|
|
@richiesta datetime,
|
|
@dataLav datetime,
|
|
@turnoLav int,
|
|
@matr varchar(10),
|
|
@guasto datetime,
|
|
@idxAmbito int,
|
|
@idxPriorita int,
|
|
@isFermo bit,
|
|
@idxTipo int,
|
|
@idxImpianto int,
|
|
@idxMacchina int,
|
|
@descrizione varchar(500),
|
|
@idxCausale int,
|
|
@scheduled bit,
|
|
@numIntMtz int output
|
|
)
|
|
AS
|
|
|
|
BEGIN tran
|
|
|
|
INSERT INTO InterventiMtz
|
|
(richiesta, dataLav, turnoLav, matr, guasto, idxAmbito, idxPriorita, isFermo, idxTipo, idxImpianto, idxMacchina, descrizione, idxStato, idxCausale, scheduled)
|
|
VALUES (@richiesta,@dataLav,@turnoLav,@matr,@guasto,@idxAmbito,@idxPriorita,@isFermo,@idxTipo,@idxImpianto,@idxMacchina,@descrizione,
|
|
1,@idxCausale,@scheduled)
|
|
|
|
/*************************************
|
|
* salvo idx del nuovo record
|
|
**************************************/
|
|
SET @numIntMtz = SCOPE_IDENTITY()
|
|
|
|
COMMIT tran
|
|
|
|
RETURN (@numIntMtz)
|
|
go
|
|
|
|
commit
|
|
go
|
|
|
|
|
|
/* aggiorno: se Ambito Guasto è 7 allora è mtz Prog... */
|
|
UPDATE InterventiMtz
|
|
SET scheduled = 1
|
|
WHERE (idxAmbito = 7)
|
|
GO
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(6, GETDATE())
|
|
GO
|