You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ITSM/.svn/pristine/cd/cde265bfc381f49b3fb5175c963...

104 lines
11 KiB

USE [Vertragsverwaltung_20160404]
GO
/****** Object: StoredProcedure [dbo].[pr_VertragselementApplikation_selectall_bottomtable] Script Date: 02.12.2016 09:08:54 ******/
DROP PROCEDURE [dbo].[pr_VertragselementApplikation_selectall_bottomtable]
GO
/****** Object: StoredProcedure [dbo].[pr_VertragselementApplikation_selectall_bottomtable] Script Date: 02.12.2016 09:08:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [dbo].[pr_VertragselementApplikation_selectall_bottomtable]
@iErrorCode int OUTPUT,
@Fokus int,
@KeyValue int,
@mitarbeiternr int
AS
if @fokus=0 begin
-- SELECT 0 AS VertragselementApplikationNr, dbo.Vertragselement.Vertragselementnr, dbo.Applikation.ApplikationNr, dbo.Vertragselement.Bezeichnung AS Vertragselement,
-- dbo.Applikation.Bezeichnung AS Applikation, '' AS Bemerkung, dbo.Applikation.Aktiv, dbo.Applikation.Erstellt_am, dbo.Applikation.Mutiert_am,
-- dbo.Applikation.Mutierer
-- FROM dbo.Vertragselement INNER JOIN
-- dbo.Applikation ON dbo.Vertragselement.ApplikationNr = dbo.Applikation.ApplikationNr
-- WHERE (dbo.Vertragselement.Vertragselementnr = @keyvalue)
-- 20091026
--SELECT dbo.VertragselementApplikation.VertragselementApplikationnr, dbo.VertragselementApplikation.Vertragselementnr,
-- dbo.VertragselementApplikation.Applikationnr, dbo.Vertragselement.Bezeichnung AS Vertragselement, dbo.Applikation.Bezeichnung AS Applikation,
-- dbo.VertragselementApplikation.Bemerkung, dbo.VertragselementApplikation.Aktiv, dbo.VertragselementApplikation.Erstellt_am,
-- dbo.VertragselementApplikation.Mutiert_am, dbo.VertragselementApplikation.Mutierer, 0 AS Lizenzen
--into #tmpa
--FROM dbo.VertragselementApplikation INNER JOIN
-- dbo.Vertragselement ON dbo.VertragselementApplikation.Vertragselementnr = dbo.Vertragselement.Vertragselementnr INNER JOIN
-- dbo.Applikation ON dbo.VertragselementApplikation.Applikationnr = dbo.Applikation.ApplikationNr
--WHERE (dbo.VertragselementApplikation.Vertragselementnr = @keyvalue) AND (dbo.Applikation.SecurityLevelNr in (select SecurityLevelNr from dbo.Get_SecurityLevelTab(@mitarbeiternr)))
--ORDER BY Applikation
SELECT TOP (100) PERCENT dbo.VertragselementApplikation.VertragselementApplikationnr, dbo.VertragselementApplikation.Vertragselementnr,
dbo.VertragselementApplikation.Applikationnr, dbo.Vertragselement.Bezeichnung AS Vertragselement, dbo.Applikation.Bezeichnung AS Applikation,
dbo.VertragselementApplikation.Bemerkung, dbo.VertragselementApplikation.Aktiv, dbo.VertragselementApplikation.Erstellt_am,
dbo.VertragselementApplikation.Mutiert_am, dbo.VertragselementApplikation.Mutierer, 0 AS Lizenzen, dbo.ApplikationVersion.Version,
dbo.ApplikationVersion.ApplikationNr AS Expr1, dbo.VertragselementApplikation.ApplikationVersionNr
into #tmpa
FROM dbo.VertragselementApplikation INNER JOIN
dbo.Vertragselement ON dbo.VertragselementApplikation.Vertragselementnr = dbo.Vertragselement.Vertragselementnr INNER JOIN
dbo.Applikation ON dbo.VertragselementApplikation.Applikationnr = dbo.Applikation.ApplikationNr LEFT OUTER JOIN
dbo.ApplikationVersion ON dbo.VertragselementApplikation.ApplikationVersionNr = dbo.ApplikationVersion.ApplikationVersionNr
WHERE (dbo.VertragselementApplikation.Vertragselementnr = @keyvalue) AND (dbo.Applikation.SecurityLevelNr in (select SecurityLevelNr from dbo.Get_SecurityLevelTab(@mitarbeiternr)))
-- and dbo.VertragselementApplikation.Aktiv=1
ORDER BY Applikation
declare @vnr int
declare @venr int
declare @anr int
declare @cnt int
declare @avnr int
declare xc cursor for
select vertragselementapplikationnr, vertragselementnr, applikationnr, applikationversionnr from #tmpa
open xc
fetch next from xc into @vnr, @venr, @anr, @avnr
while @@FETCH_STATUS=0 begin
select @cnt=COUNT(*) from Lizenzkauf where vertragselementapplikationnr=@vnr and Aktiv=1
if @cnt > 0 update #tmpa set lizenzen=1 where VertragselementApplikationnr=@vnr
fetch next from xc into @vnr, @venr, @anr,@avnr
end
close xc
deallocate xc
select * from #tmpa
drop table #tmpa
end else begin
SELECT dbo.VertragselementApplikation.VertragselementApplikationnr,
dbo.VertragselementApplikation.Vertragselementnr,
dbo.VertragselementApplikation.Applikationnr,
dbo.Vertragselement.Bezeichnung as Vertragselement, dbo.Applikation.Bezeichnung AS Applikation,
dbo.VertragselementApplikation.Bemerkung, dbo.VertragselementApplikation.Aktiv,
dbo.VertragselementApplikation.Erstellt_am, dbo.VertragselementApplikation.Mutiert_am,
dbo.VertragselementApplikation.Mutierer
FROM dbo.VertragselementApplikation INNER JOIN
dbo.Vertragselement ON dbo.VertragselementApplikation.Vertragselementnr = dbo.Vertragselement.Vertragselementnr INNER JOIN
dbo.Applikation ON dbo.VertragselementApplikation.Applikationnr = dbo.Applikation.ApplikationNr
where dbo.vertragselementapplikation.applikationnr=@keyvalue and
dbo.vertragselement.SecurityLevelnrin (select SecurityLevelNr from dbo.Get_SecurityLevelTab(@mitarbeiternr))
order by dbo.applikation.bezeichnung
end
-- Get the Error Code for the statement just executed.
SELECT @iErrorCode=@@ERROR
GO