254 lines
5.4 KiB
Transact-SQL
254 lines
5.4 KiB
Transact-SQL
create table AnagAzioniUtente(
|
|
codAzione nvarchar(10) not null constraint PK_AnagAzioniUtente primary key,
|
|
descrAzione nvarchar(50)
|
|
);
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
INSERT INTO dbo.AnagAzioniUtente
|
|
VALUES (N'consumaUDC', N'consuma UDC')
|
|
INSERT INTO dbo.AnagAzioniUtente
|
|
VALUES (N'creaUDC', N'creazione nuovo UDC')
|
|
INSERT INTO dbo.AnagAzioniUtente
|
|
VALUES (N'eliminaUDC', N'elimina UDC')
|
|
INSERT INTO dbo.AnagAzioniUtente
|
|
VALUES (N'stampaUDC', N'stampa UDC')
|
|
go
|
|
|
|
commit transaction
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
create table StoricoAzioniOperatore(
|
|
idxEvento int not null identity constraint PK_StoricoAzioniOperatore primary key,
|
|
DataOra datetime not null,
|
|
CodSoggetto nchar(17) not null,
|
|
codPostazione nvarchar(250),
|
|
UDC nvarchar(50),
|
|
Particolare nvarchar(15),
|
|
codAzione nvarchar(10),
|
|
descrizione nvarchar(50)
|
|
);
|
|
go
|
|
|
|
alter table StoricoAzioniOperatore add
|
|
constraint FK_StoricoAzioniOperatore_AnagAzioniUtente foreign key(codAzione) references AnagAzioniUtente(codAzione) on update cascade;
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_SAO_insert
|
|
*
|
|
* effettua ricerca nello Storico Azioni Operatore
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.09.25
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_SAO_getBySearch
|
|
(
|
|
@DataOraFrom DATETIME,
|
|
@DataOraTo DATETIME,
|
|
@CodSoggetto NVARCHAR(17)='',
|
|
@codPostazione NVARCHAR(250)='',
|
|
@UDC NVARCHAR(50)='',
|
|
@Particolare NVARCHAR(15)='',
|
|
@codAzione NVARCHAR(10)=''
|
|
)
|
|
AS
|
|
|
|
SELECT *
|
|
FROM StoricoAzioni
|
|
WHERE DataOra BETWEEN @DataOraFrom AND @DataOraTo
|
|
AND CodSoggetto = CASE WHEN @CodSoggetto = '' THEN CodSoggetto ELSE @CodSoggetto END
|
|
AND codPostazione = CASE WHEN @codPostazione = '' THEN codPostazione ELSE @codPostazione END
|
|
AND UDC = CASE WHEN @UDC = '' THEN UDC ELSE @UDC END
|
|
AND Particolare = CASE WHEN @Particolare = '' THEN Particolare ELSE @Particolare END
|
|
AND codAzione = CASE WHEN @codAzione = '' THEN codAzione ELSE @codAzione END
|
|
|
|
COMMIT tran
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_SAO_insert
|
|
*
|
|
* inserisce nuova riga nello Storico Azioni Operatore
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.09.25
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_SAO_insert
|
|
(
|
|
@DataOra DATETIME,
|
|
@CodSoggetto NVARCHAR(17),
|
|
@codPostazione NVARCHAR(250),
|
|
@UDC NVARCHAR(50),
|
|
@Particolare NVARCHAR(15),
|
|
@codAzione NVARCHAR(10),
|
|
@descrizione NVARCHAR(50)
|
|
)
|
|
AS
|
|
|
|
BEGIN tran
|
|
|
|
-- inserisco nuovo record storico azioni operatore
|
|
INSERT INTO StoricoAzioni(DataOra, CodSoggetto, codPostazione, UDC, Particolare, codAzione, descrizione)
|
|
VALUES (@DataOra, @CodSoggetto, @codPostazione, @UDC, @Particolare, @codAzione, @descrizione)
|
|
|
|
COMMIT tran
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
drop table StoricoAzioniOperatore;
|
|
go
|
|
|
|
create table StoricoAzioniOperatore(
|
|
idxEvento int not null identity constraint PK_StoricoAzioniOperatore primary key,
|
|
DataOra datetime not null,
|
|
CodSoggetto nchar(17) not null,
|
|
codPostazione nvarchar(250),
|
|
clientIP nvarchar(250),
|
|
UDC nvarchar(50),
|
|
Particolare nvarchar(15),
|
|
codAzione nvarchar(10),
|
|
descrizione nvarchar(50)
|
|
);
|
|
go
|
|
|
|
alter table StoricoAzioniOperatore add
|
|
constraint FK_StoricoAzioniOperatore_AnagAzioniUtente foreign key(codAzione) references AnagAzioniUtente(codAzione) on update cascade;
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_SAO_insert
|
|
*
|
|
* effettua ricerca nello Storico Azioni Operatore
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.09.25
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_SAO_getBySearch
|
|
(
|
|
@DataOraFrom DATETIME,
|
|
@DataOraTo DATETIME,
|
|
@CodSoggetto NVARCHAR(17)='',
|
|
@codPostazione NVARCHAR(250)='',
|
|
@clientIp NVARCHAR(250)='',
|
|
@UDC NVARCHAR(50)='',
|
|
@Particolare NVARCHAR(15)='',
|
|
@codAzione NVARCHAR(10)=''
|
|
)
|
|
AS
|
|
|
|
SELECT *
|
|
FROM StoricoAzioni
|
|
WHERE DataOra BETWEEN @DataOraFrom AND @DataOraTo
|
|
AND CodSoggetto = CASE WHEN @CodSoggetto = '' THEN CodSoggetto ELSE @CodSoggetto END
|
|
AND codPostazione = CASE WHEN @codPostazione = '' THEN codPostazione ELSE @codPostazione END
|
|
AND clientIp = CASE WHEN @clientIp = '' THEN clientIp ELSE @clientIp END
|
|
AND UDC = CASE WHEN @UDC = '' THEN UDC ELSE @UDC END
|
|
AND Particolare = CASE WHEN @Particolare = '' THEN Particolare ELSE @Particolare END
|
|
AND codAzione = CASE WHEN @codAzione = '' THEN codAzione ELSE @codAzione END
|
|
|
|
COMMIT tran
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_SAO_insert
|
|
*
|
|
* inserisce nuova riga nello Storico Azioni Operatore
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.09.25
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_SAO_insert
|
|
(
|
|
@DataOra DATETIME,
|
|
@CodSoggetto NVARCHAR(17),
|
|
@codPostazione NVARCHAR(250),
|
|
@clientIp NVARCHAR(250)='',
|
|
@UDC NVARCHAR(50),
|
|
@Particolare NVARCHAR(15),
|
|
@codAzione NVARCHAR(10),
|
|
@descrizione NVARCHAR(50)
|
|
)
|
|
AS
|
|
|
|
BEGIN tran
|
|
|
|
-- inserisco nuovo record storico azioni operatore
|
|
INSERT INTO StoricoAzioni(DataOra, CodSoggetto, codPostazione, clientIp, UDC, Particolare, codAzione, descrizione)
|
|
VALUES (@DataOra, @CodSoggetto, @codPostazione, @clientIp, @UDC, @Particolare, @codAzione, @descrizione)
|
|
|
|
COMMIT tran
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(495, GETDATE())
|
|
GO
|