1a3fb2f0e4
- correzione bug underscore vari - fix SQL x gestione lettura comemsse da PROJ + gestioen update underscore "storici"
465 lines
11 KiB
Transact-SQL
465 lines
11 KiB
Transact-SQL
|
|
/****** Object: View [dbo].[v_selCommesse_old] Script Date: 29/08/2013 15.59.37 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
|
|
CREATE VIEW [dbo].[v_selCommesse_old]
|
|
AS
|
|
SELECT dbo.f_padLeft(NrComme, 4, '0') + '-' + Anno COLLATE SQL_Latin1_General_CP1_CI_AS AS value, '(' + dbo.f_padLeft(NrComme, 4, '0')
|
|
+ '-' + Anno + ') ' + Commitente + ' | ' + Descrizione + ' [' + dbo.f_shortFormComm(NrComme, Anno) + ']' COLLATE SQL_Latin1_General_CP1_CI_AS AS label
|
|
FROM XPANDING.SciP.dbo.Commesse
|
|
|
|
UNION
|
|
|
|
SELECT DISTINCT ('0000-' + Anno) COLLATE SQL_Latin1_General_CP1_CI_AS AS value,
|
|
'0000-' + CAST(Anno AS NVARCHAR(4)) + ' - senza commessa' + ' [' + dbo.f_shortFormComm(0, Anno) + ']' COLLATE SQL_Latin1_General_CP1_CI_AS AS label
|
|
FROM XPANDING.SciP.dbo.Commesse
|
|
|
|
UNION
|
|
|
|
SELECT '0000-' + CAST(YEAR(GETDATE()) AS NVARCHAR(4)) COLLATE SQL_Latin1_General_CP1_CI_AS AS value,
|
|
'0000-' + CAST(YEAR(GETDATE()) AS NVARCHAR(4)) + ' - senza commessa anno corrente' + ' [' + dbo.f_shortFormComm(0, YEAR(GETDATE())) + ']' COLLATE SQL_Latin1_General_CP1_CI_AS AS label
|
|
|
|
|
|
|
|
|
|
GO
|
|
|
|
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
|
Begin DesignProperties =
|
|
Begin PaneConfigurations =
|
|
Begin PaneConfiguration = 0
|
|
NumPanes = 4
|
|
Configuration = "(H (1[41] 4[20] 2[14] 3) )"
|
|
End
|
|
Begin PaneConfiguration = 1
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 4 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 2
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 2 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 3
|
|
NumPanes = 3
|
|
Configuration = "(H (4 [30] 2 [40] 3))"
|
|
End
|
|
Begin PaneConfiguration = 4
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [56] 3))"
|
|
End
|
|
Begin PaneConfiguration = 5
|
|
NumPanes = 2
|
|
Configuration = "(H (2 [66] 3))"
|
|
End
|
|
Begin PaneConfiguration = 6
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [50] 3))"
|
|
End
|
|
Begin PaneConfiguration = 7
|
|
NumPanes = 1
|
|
Configuration = "(V (3))"
|
|
End
|
|
Begin PaneConfiguration = 8
|
|
NumPanes = 3
|
|
Configuration = "(H (1[56] 4[18] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 9
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [75] 4))"
|
|
End
|
|
Begin PaneConfiguration = 10
|
|
NumPanes = 2
|
|
Configuration = "(H (1[66] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 11
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [60] 2))"
|
|
End
|
|
Begin PaneConfiguration = 12
|
|
NumPanes = 1
|
|
Configuration = "(H (1) )"
|
|
End
|
|
Begin PaneConfiguration = 13
|
|
NumPanes = 1
|
|
Configuration = "(V (4))"
|
|
End
|
|
Begin PaneConfiguration = 14
|
|
NumPanes = 1
|
|
Configuration = "(V (2))"
|
|
End
|
|
ActivePaneConfig = 0
|
|
End
|
|
Begin DiagramPane =
|
|
Begin Origin =
|
|
Top = 0
|
|
Left = 0
|
|
End
|
|
Begin Tables =
|
|
Begin Table = "Commesse_1"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 114
|
|
Right = 213
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 35
|
|
Width = 284
|
|
Width = 1500
|
|
Width = 9480
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 3750
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 8565
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
End
|
|
End
|
|
Begin CriteriaPane =
|
|
Begin ColumnWidths = 11
|
|
Column = 1440
|
|
Alias = 900
|
|
Table = 1170
|
|
Output = 720
|
|
Append = 1400
|
|
NewValue = 1170
|
|
SortType = 1350
|
|
SortOrder = 1410
|
|
GroupBy = 1350
|
|
Filter = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
End
|
|
End
|
|
End
|
|
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_selCommesse_old'
|
|
GO
|
|
|
|
EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'v_selCommesse_old'
|
|
GO
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
alter VIEW v_selCommesse
|
|
AS
|
|
SELECT *
|
|
FROM ETS_PROJ.dbo.v_selCommRicerca
|
|
|
|
UNION
|
|
|
|
SELECT *
|
|
FROM ETS_PROJ.dbo.v_selCommZeroMancanti
|
|
go
|
|
|
|
exec sp_updateextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
|
Begin DesignProperties =
|
|
Begin PaneConfigurations =
|
|
Begin PaneConfiguration = 0
|
|
NumPanes = 4
|
|
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
|
End
|
|
Begin PaneConfiguration = 1
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 4 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 2
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 2 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 3
|
|
NumPanes = 3
|
|
Configuration = "(H (4 [30] 2 [40] 3))"
|
|
End
|
|
Begin PaneConfiguration = 4
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [56] 3))"
|
|
End
|
|
Begin PaneConfiguration = 5
|
|
NumPanes = 2
|
|
Configuration = "(H (2 [66] 3))"
|
|
End
|
|
Begin PaneConfiguration = 6
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [50] 3))"
|
|
End
|
|
Begin PaneConfiguration = 7
|
|
NumPanes = 1
|
|
Configuration = "(V (3))"
|
|
End
|
|
Begin PaneConfiguration = 8
|
|
NumPanes = 3
|
|
Configuration = "(H (1[56] 4[18] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 9
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [75] 4))"
|
|
End
|
|
Begin PaneConfiguration = 10
|
|
NumPanes = 2
|
|
Configuration = "(H (1[66] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 11
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [60] 2))"
|
|
End
|
|
Begin PaneConfiguration = 12
|
|
NumPanes = 1
|
|
Configuration = "(H (1) )"
|
|
End
|
|
Begin PaneConfiguration = 13
|
|
NumPanes = 1
|
|
Configuration = "(V (4))"
|
|
End
|
|
Begin PaneConfiguration = 14
|
|
NumPanes = 1
|
|
Configuration = "(V (2))"
|
|
End
|
|
ActivePaneConfig = 0
|
|
End
|
|
Begin DiagramPane =
|
|
Begin Origin =
|
|
Top = 0
|
|
Left = 0
|
|
End
|
|
Begin Tables =
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 35
|
|
Width = 284
|
|
Width = 1500
|
|
Width = 9480
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 3750
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 8565
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
End
|
|
End
|
|
Begin CriteriaPane =
|
|
Begin ColumnWidths = 11
|
|
Column = 1440
|
|
Alias = 900
|
|
Table = 1170
|
|
Output = 720
|
|
Append = 1400
|
|
NewValue = 1170
|
|
SortType = 1350
|
|
SortOrder = 1410
|
|
GroupBy = 1350
|
|
Filter = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
End
|
|
End
|
|
End
|
|
', 'SCHEMA', 'dbo', 'VIEW', 'v_selCommesse';
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_tbDocs_searchByNrProto
|
|
*
|
|
* cerca documenti con condizione like su numero protocollo xxxx-aaaa
|
|
*
|
|
* mod : 2013.07.15
|
|
* aut : S.E. Locatelli
|
|
**************************************/
|
|
create PROCEDURE stp_tbDocs_searchByNrProto
|
|
(
|
|
@search NVARCHAR(20)
|
|
)
|
|
|
|
AS
|
|
|
|
-- se contiene '-' significa ricerca numero + anno separata
|
|
DECLARE @chIdx INT = 0
|
|
SET @chIdx = CHARINDEX('-',@search)
|
|
IF(@chIdx > 0)
|
|
BEGIN
|
|
|
|
--SELECT SUBSTRING(@search,1,@chIdx-1) as ex1, SUBSTRING(@search,@chIdx+1,4) as ex2
|
|
|
|
SELECT *
|
|
FROM tbDocumenti
|
|
WHERE Numero = SUBSTRING(@search,1,@chIdx-1)-- LIKE '%'+SUBSTRING(@search,1,@chIdx-1)+'%' -- se volessi fare search like...
|
|
AND Anno LIKE '%'+SUBSTRING(@search,@chIdx+1,4)+'%'
|
|
ORDER BY Anno DESC, Numero DESC
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
-- altrimenti ricerco o numero o anno...
|
|
SELECT *
|
|
FROM tbDocumenti
|
|
WHERE Numero LIKE '%'+@search+'%'
|
|
OR Anno LIKE '%'+@search+'%'
|
|
ORDER BY Anno DESC, Numero DESC
|
|
END
|
|
|
|
RETURN
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_selDocs_searchByNrProto
|
|
*
|
|
* cerca documenti con condizione like su numero protocollo xxxx-aaaa --> restituisce vista v_selDovs
|
|
*
|
|
* mod : 2013.07.15
|
|
* aut : S.E. Locatelli
|
|
**************************************/
|
|
create PROCEDURE stp_VSD_searchByNrProto
|
|
(
|
|
@search NVARCHAR(20)
|
|
)
|
|
|
|
AS
|
|
|
|
-- se contiene '-' significa ricerca numero + anno separata
|
|
DECLARE @chIdx INT = 0
|
|
SET @chIdx = CHARINDEX('-',@search)
|
|
IF(@chIdx > 0)
|
|
BEGIN
|
|
|
|
--SELECT SUBSTRING(@search,1,@chIdx-1) as ex1, SUBSTRING(@search,@chIdx+1,4) as ex2
|
|
|
|
SELECT CAST(Numero AS NVARCHAR(50)) + '-' + CAST(Anno AS NVARCHAR(50)) as value, CAST(Numero AS NVARCHAR(50)) + '-' + CAST(Anno AS NVARCHAR(50)) + ' | ' + Fonte + ' - ' + Oggetto as label
|
|
FROM tbDocumenti
|
|
WHERE Numero = SUBSTRING(@search,1,@chIdx-1)-- LIKE '%'+SUBSTRING(@search,1,@chIdx-1)+'%' -- se volessi fare search like...
|
|
AND Anno LIKE '%'+SUBSTRING(@search,@chIdx+1,4)+'%'
|
|
ORDER BY Anno DESC, Numero DESC
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
-- altrimenti ricerco o numero o anno...
|
|
SELECT CAST(Numero AS NVARCHAR(50)) + '-' + CAST(Anno AS NVARCHAR(50)) as value, CAST(Numero AS NVARCHAR(50)) + '-' + CAST(Anno AS NVARCHAR(50)) + ' | ' + Fonte + ' - ' + Oggetto as label
|
|
FROM tbDocumenti
|
|
WHERE Numero LIKE '%'+@search+'%'
|
|
OR Anno LIKE '%'+@search+'%'
|
|
ORDER BY Anno DESC, Numero DESC
|
|
END
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
-- ora aggiorno dati inseriti x fase, fonte, oggetto....
|
|
|
|
UPDATE tbDocumenti
|
|
SET Fase = REPLACE(Fase, '_',' ')
|
|
WHERE Fase like '%[_]%'
|
|
GO
|
|
|
|
UPDATE tbDocumenti
|
|
SET Fonte = REPLACE(Fonte, '_',' ')
|
|
WHERE Fonte like '%[_]%'
|
|
GO
|
|
|
|
UPDATE tbDocumenti
|
|
SET Oggetto = REPLACE(Oggetto, '_',' ')
|
|
WHERE Oggetto like '%[_]%'
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(137, GETDATE())
|
|
GO
|
|
SELECT TOP 10 * FROM LogUpdateDb ORDER BY Versione DESC
|
|
GO
|