Commit a56222b735d8ee679e6ee8bac2a9afcc27da2422
1 parent
aea2ab03
New Proc
Showing
9 changed files
with
472 additions
and
0 deletions
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_DeleteSiteAccount.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_DeleteSiteAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_DeleteSiteAccount] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 08-Feb-2018 | |
13 | +-- Description: To delete a site account for a license account and site | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_DeleteSiteAccount] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @iSiteId int, @LicenseId int, @UserId int, | |
18 | + @Status bit out | |
19 | +AS | |
20 | +BEGIN | |
21 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
22 | + -- interfering with SELECT statements. | |
23 | +SET NOCOUNT ON; | |
24 | + | |
25 | + set @Status = 0; | |
26 | + BEGIN TRY | |
27 | + BEGIN TRANSACTION | |
28 | + | |
29 | + delete SLE from SiteToLicenseEdition SLE inner join LicenseToEdition LE on SLE.LicenseEditionId = LE.Id where SLE.SiteId = @iSiteId and LicenseId = @LicenseId; | |
30 | + delete from AIAUserToSite where SiteId = @iSiteId and UserId = @UserId; | |
31 | + delete from Site where Id = @iSiteId; | |
32 | + | |
33 | + COMMIT TRANSACTION | |
34 | + set @Status = 1; | |
35 | + END TRY | |
36 | + BEGIN CATCH | |
37 | + IF @@TRANCOUNT > 0 | |
38 | + ROLLBACK TRANSACTION | |
39 | + END CATCH | |
40 | + | |
41 | +END | |
42 | + | |
43 | +GO | |
44 | +SET QUOTED_IDENTIFIER OFF | |
45 | +GO | |
46 | +SET ANSI_NULLS ON | |
47 | +GO | |
48 | + | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetAccountNumber.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetAccountNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_GetAccountNumber] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 23-Dec-2009 | |
13 | +-- Description: To get the license id and account no of licenses of a type | |
14 | +-- ==================================================== | |
15 | +CREATE PROCEDURE [dbo].[usp_GetAccountNumber] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @LicenseType int | |
18 | +AS | |
19 | +BEGIN | |
20 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
21 | + -- interfering with SELECT statements. | |
22 | + SET NOCOUNT ON; | |
23 | + if(@LicenseType = 0) | |
24 | + begin | |
25 | + SELECT License.Id,License.AccountNumber FROM License | |
26 | + WHERE License.IsActive = 1 | |
27 | + end | |
28 | + else | |
29 | + begin | |
30 | + SELECT License.Id,License.AccountNumber FROM License | |
31 | + WHERE License.IsActive = 1 and License.LicenseTypeId = @LicenseType | |
32 | + end | |
33 | +END | |
34 | + | |
35 | +GO | |
36 | +SET QUOTED_IDENTIFIER OFF | |
37 | +GO | |
38 | +SET ANSI_NULLS ON | |
39 | +GO | |
40 | + | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetLicenseModestySettings.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetLicenseModestySettings]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_GetLicenseModestySettings] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 05-Feb-2018 | |
13 | +-- Description: To get all the modesty settings of a license and its related editions | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_GetLicenseModestySettings] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @iLicenseId int, @iBuildingLevelId int | |
18 | +AS | |
19 | +BEGIN | |
20 | + | |
21 | + IF 1=0 BEGIN | |
22 | + SET FMTONLY OFF | |
23 | + END | |
24 | + | |
25 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
26 | + -- interfering with SELECT statements. | |
27 | + SET NOCOUNT ON; | |
28 | + IF @iBuildingLevelId = 0 | |
29 | + BEGIN | |
30 | + SELECT LicenseToEdition.Id as LicenseEditionId, Edition.Title, LicenseToEdition.IsModesty as IsModesty | |
31 | + FROM LicenseToEdition | |
32 | + INNER JOIN Edition ON LicenseToEdition.EditionId = Edition.Id | |
33 | + WHERE LicenseToEdition.LicenseId=@iLicenseId and Edition.IsActive=1 ORDER BY Edition.Priority | |
34 | + END | |
35 | + ELSE | |
36 | + BEGIN | |
37 | + SELECT LicenseToEdition.Id as LicenseEditionId, Edition.Title, SiteToLicenseEdition.IsModesty as IsModesty | |
38 | + FROM SiteToLicenseEdition | |
39 | + INNER JOIN LicenseToEdition ON SiteToLicenseEdition.LicenseEditionId = LicenseToEdition.Id | |
40 | + INNER JOIN Edition ON LicenseToEdition.EditionId = Edition.Id | |
41 | + WHERE SiteToLicenseEdition.SiteId=@iBuildingLevelId and Edition.IsActive=1 ORDER BY Edition.Priority | |
42 | + END | |
43 | + | |
44 | +END | |
45 | + | |
46 | +GO | |
47 | +SET QUOTED_IDENTIFIER OFF | |
48 | +GO | |
49 | +SET ANSI_NULLS ON | |
50 | +GO | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSiteAccountEditions.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteAccountEditions]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_GetSiteAccountEditions] | |
8 | +GO | |
9 | +-- ==================================================== | |
10 | +-- Author: Magic Software | |
11 | +-- Create date: 07-Feb-2018 | |
12 | +-- Description: To get a site account editions on the basis of siteid and licenseid | |
13 | +-- ==================================================== | |
14 | +create PROCEDURE [dbo].[usp_GetSiteAccountEditions] | |
15 | + -- Add the parameters for the stored procedure here | |
16 | + @SiteId int, | |
17 | + @LicenseId int | |
18 | +AS | |
19 | +BEGIN | |
20 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
21 | + -- interfering with SELECT statements. | |
22 | + SET NOCOUNT ON; | |
23 | + | |
24 | + Select SLE.LicenseEditionId, E.Id, E.Title from SiteToLicenseEdition SLE | |
25 | + inner join LicenseToEdition LE on SLE.LicenseEditionId = LE.Id | |
26 | + inner join License L on L.Id = LE.LicenseId | |
27 | + inner join Edition E on LE.EditionId = E.Id | |
28 | + where L.Id = @LicenseId and SLE.SiteId = @SiteId; | |
29 | + | |
30 | +END | |
31 | + | |
32 | +GO | |
33 | +SET QUOTED_IDENTIFIER OFF | |
34 | +GO | |
35 | +SET ANSI_NULLS ON | |
36 | +GO | |
0 | 37 | \ No newline at end of file | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSiteById.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteById]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_GetSiteById] | |
8 | +GO | |
9 | +-- ==================================================== | |
10 | +-- Author: Magic Software | |
11 | +-- Create date: 07-Feb-2018 | |
12 | +-- Description: To get a site information on the basis of siteid | |
13 | +-- ==================================================== | |
14 | +create PROCEDURE [dbo].[usp_GetSiteById] | |
15 | + -- Add the parameters for the stored procedure here | |
16 | + @SiteId int | |
17 | +AS | |
18 | +BEGIN | |
19 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
20 | + -- interfering with SELECT statements. | |
21 | + SET NOCOUNT ON; | |
22 | + | |
23 | + Select Site.Id,Site.SiteIp,Site.Title,ISNULL(Site.SiteIPTo,'') as SiteIPTo,ISNULL(Site.SiteMasterIPTo,'') as SiteMasterIPTo, Site.Address1, Site.Address2, | |
24 | + Site.Zip, Site.Phone, Site.City, Site.StateId, Site.CountryId, Site.IsMaster, Site.IsActive, | |
25 | + CONVERT(VARCHAR,Site.CreationDate,101) as CreationDate, | |
26 | + CONVERT(VARCHAR,Site.ModifiedDate,101) as ModifiedDate, | |
27 | + Site.InstituteName,Site.Department, AIAUser.Id as UserId,AIAUser.FirstName,AIAUser.EmailId | |
28 | + From ((Site INNER JOIN AIAUserToSite on Site.Id=AIAUserToSite.SiteId) | |
29 | + INNER JOIN AIAUser on AIAUserToSite.UserId = AIAUser.Id) | |
30 | + Where Site.id = @SiteId; | |
31 | + | |
32 | + | |
33 | +END | |
34 | + | |
35 | +GO | |
36 | +SET QUOTED_IDENTIFIER OFF | |
37 | +GO | |
38 | +SET ANSI_NULLS ON | |
39 | +GO | |
0 | 40 | \ No newline at end of file | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertUpdateSiteAccount.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertUpdateSiteAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_InsertUpdateSiteAccount] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 08-Feb-2018 | |
13 | +-- Description: To insert or update a site account for a license account and site | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_InsertUpdateSiteAccount] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @iSiteId int, @sSiteIP varchar(2000), @sTitle varchar(100), @sInstituteName varchar(100), @sDepartment varchar(50), | |
18 | + @sAddress1 varchar(100), @sAddress2 varchar(100), @sCity varchar(50), @Zip varchar(20), @Phone varchar(30), | |
19 | + @StateId int, @CountryId int, @IsMaster bit, @CreationDate datetime, @ModifiedDate datetime, | |
20 | + @IsActive bit, @UserId int, @sSiteIPTo varchar(100), @LicenseId int, @SiteEditionIds varchar(1000), | |
21 | + @Status bit out | |
22 | +AS | |
23 | +BEGIN | |
24 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
25 | + -- interfering with SELECT statements. | |
26 | +SET NOCOUNT ON; | |
27 | + | |
28 | +DECLARE @list varchar(1000) | |
29 | +DECLARE @pos INT, @tempEditionId int, @tempLicenseEditionId int; | |
30 | +DECLARE @len INT, @tempModesty bit; | |
31 | +DECLARE @value varchar(1000) | |
32 | + | |
33 | +CREATE TABLE #LocalTempTable( | |
34 | +SiteId int, | |
35 | +LicenseEditionId int, | |
36 | +IsModesty bit); | |
37 | + | |
38 | +if(@SiteEditionIds != '') | |
39 | +begin | |
40 | + set @SiteEditionIds = @SiteEditionIds + ','; | |
41 | +end | |
42 | +SET @list = @SiteEditionIds | |
43 | + | |
44 | + set @Status = 0; | |
45 | + BEGIN TRY | |
46 | + BEGIN TRANSACTION | |
47 | + | |
48 | + IF @iSiteId = 0 | |
49 | + BEGIN | |
50 | + INSERT INTO [dbo].[Site]([SiteIP],[Title],[InstituteName],[Department],[Address1],[Address2], | |
51 | + [City],[Zip],[Phone],[StateId],[CountryId],[IsMaster],[CreationDate],[ModifiedDate],[IsActive],[SiteIPTo]) | |
52 | + VALUES(@sSiteIP, @sTitle, @sInstituteName, @sDepartment, @sAddress1, @sAddress2, @sCity, @Zip, @Phone, | |
53 | + @StateId, @CountryId, @IsMaster, @CreationDate, @ModifiedDate, @IsActive, @sSiteIPTo); | |
54 | + -- to get the last inserted identity value in the current session | |
55 | + SET @iSiteId=SCOPE_IDENTITY(); | |
56 | + insert into AIAUserToSite values(@UserId, @iSiteId); | |
57 | + END | |
58 | + ELSE | |
59 | + BEGIN | |
60 | + UPDATE [dbo].[Site] SET [SiteIP]=@sSiteIP, [Title]=@sTitle,[InstituteName]=@sInstituteName, | |
61 | + [Department]=@sDepartment, [Address1]=@sAddress1, [Address2]=@sAddress2,[City]=@sCity, | |
62 | + [Zip]=@Zip, [Phone]=@Phone, [StateId]=@StateId, [CountryId]=@CountryId, | |
63 | + [ModifiedDate]=@ModifiedDate, [IsActive]=@IsActive, [SiteIPTo]=@sSiteIPTo | |
64 | + WHERE [Id]=@iSiteId | |
65 | + END | |
66 | + | |
67 | + insert into #LocalTempTable | |
68 | + select SLE.* from SiteToLicenseEdition SLE inner join LicenseToEdition LE on SLE.LicenseEditionId = LE.Id where | |
69 | + SLE.SiteId = @iSiteId and LicenseId = @LicenseId; | |
70 | + | |
71 | + delete SLE from SiteToLicenseEdition SLE inner join LicenseToEdition LE on SLE.LicenseEditionId = LE.Id where | |
72 | + SLE.SiteId = @iSiteId and LicenseId = @LicenseId; | |
73 | + | |
74 | + set @pos = 0 | |
75 | + set @len = 0 | |
76 | + | |
77 | + WHILE CHARINDEX(',', @list, @pos+1)>0 | |
78 | + BEGIN | |
79 | + set @len = CHARINDEX(',', @list, @pos+1) - @pos; | |
80 | + set @value = SUBSTRING(@list, @pos, @len); | |
81 | + set @tempEditionId = convert(int, @value); | |
82 | + select @tempLicenseEditionId = Id from LicenseToEdition where LicenseId = @LicenseId and EditionId = @tempEditionId; | |
83 | + set @tempModesty = 0; | |
84 | + if(exists(select * from #LocalTempTable where LicenseEditionId = @tempLicenseEditionId and SiteId = @iSiteId)) | |
85 | + begin | |
86 | + select @tempModesty = IsModesty from #LocalTempTable where LicenseEditionId = @tempLicenseEditionId and SiteId = @iSiteId; | |
87 | + end | |
88 | + insert into SiteToLicenseEdition(SiteId, LicenseEditionId, IsModesty) values(@iSiteId, @tempLicenseEditionId, @tempModesty); | |
89 | + set @pos = CHARINDEX(',', @list, @pos+@len) + 1; | |
90 | + END | |
91 | + | |
92 | + COMMIT TRANSACTION | |
93 | + set @Status = 1; | |
94 | + END TRY | |
95 | + BEGIN CATCH | |
96 | + IF @@TRANCOUNT > 0 | |
97 | + ROLLBACK TRANSACTION | |
98 | + END CATCH | |
99 | + | |
100 | +END | |
101 | + | |
102 | +GO | |
103 | +SET QUOTED_IDENTIFIER OFF | |
104 | +GO | |
105 | +SET ANSI_NULLS ON | |
106 | +GO | |
107 | + | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateLicenseBasicSettings.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateLicenseBasicSettings]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_UpdateLicenseBasicSettings] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 02-Feb-2018 | |
13 | +-- Description: To update a license account basic values | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_UpdateLicenseBasicSettings] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @iLicenseId int, @sLicenseeFname varchar(50), @sLicenseeLname varchar(50), | |
18 | + @sInstitutionName varchar(100)='', @sAddress1 varchar(100)='', | |
19 | + @sAddress2 varchar(100)='', @sCity varchar(50)='', @sZip varchar(20)='', @iStateId int, @iCountryId int, | |
20 | + @sPhone varchar(30) = '', @sEmailId varchar(50), | |
21 | + @Status bit out | |
22 | +AS | |
23 | +BEGIN | |
24 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
25 | + -- interfering with SELECT statements. | |
26 | + SET NOCOUNT ON; | |
27 | + | |
28 | + set @Status = 0; | |
29 | + BEGIN TRY | |
30 | + BEGIN TRANSACTION | |
31 | + UPDATE License SET LicenseeFirstName = @sLicenseeFname, LicenseeLastName = @sLicenseeLname, | |
32 | + InstitutionName = @sInstitutionName, Address1 = @sAddress1, Address2 = @sAddress2, EmailId = @sEmailId, | |
33 | + City = @sCity, Zip = @sZip, Phone = @sPhone, StateId = @iStateId, CountryId = @iCountryId | |
34 | + where Id = @iLicenseId; | |
35 | + COMMIT TRANSACTION | |
36 | + set @Status = 1; | |
37 | + END TRY | |
38 | + BEGIN CATCH | |
39 | + IF @@TRANCOUNT > 0 | |
40 | + ROLLBACK TRANSACTION | |
41 | + END CATCH | |
42 | + | |
43 | +END | |
44 | + | |
45 | +GO | |
46 | +SET QUOTED_IDENTIFIER OFF | |
47 | +GO | |
48 | +SET ANSI_NULLS ON | |
49 | +GO | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateLicenseModestySettings.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateLicenseModestySettings]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_UpdateLicenseModestySettings] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 05-Feb-2018 | |
13 | +-- Description: To update the modesty settings of a license edition or its site | |
14 | +-- ==================================================== | |
15 | +create PROCEDURE [dbo].[usp_UpdateLicenseModestySettings] | |
16 | + -- Add the parameters for the stored procedure here | |
17 | + @LicenseEditionId int, | |
18 | + @SiteId int, | |
19 | + @IsModesty bit, | |
20 | + @Status bit out | |
21 | +AS | |
22 | +BEGIN | |
23 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
24 | + -- interfering with SELECT statements. | |
25 | + SET NOCOUNT ON; | |
26 | + | |
27 | + set @Status = 0; | |
28 | + BEGIN TRY | |
29 | + BEGIN TRANSACTION | |
30 | + if(@SiteId = 0) | |
31 | + begin | |
32 | + UPDATE LicenseToEdition SET IsModesty = @IsModesty where Id = @LicenseEditionId; | |
33 | + end | |
34 | + else | |
35 | + begin | |
36 | + UPDATE SiteToLicenseEdition SET IsModesty = @IsModesty where SiteId = @SiteId and LicenseEditionId = @LicenseEditionId; | |
37 | + end | |
38 | + COMMIT TRANSACTION | |
39 | + set @Status = 1; | |
40 | + END TRY | |
41 | + BEGIN CATCH | |
42 | + IF @@TRANCOUNT > 0 | |
43 | + ROLLBACK TRANSACTION | |
44 | + END CATCH | |
45 | + | |
46 | +END | |
47 | + | |
48 | +GO | |
49 | +SET QUOTED_IDENTIFIER OFF | |
50 | +GO | |
51 | +SET ANSI_NULLS ON | |
52 | +GO | ... | ... |
150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateLicenseModuleStatus.sql
0 → 100644
1 | +SET QUOTED_IDENTIFIER ON | |
2 | +GO | |
3 | +SET ANSI_NULLS ON | |
4 | +GO | |
5 | + | |
6 | +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateLicenseModuleStatus]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) | |
7 | +drop procedure [dbo].[usp_UpdateLicenseModuleStatus] | |
8 | +GO | |
9 | + | |
10 | +-- ==================================================== | |
11 | +-- Author: Magic Software | |
12 | +-- Create date: 06-Feb-2018 | |
13 | +-- Description: To insert or update the module status on or off for a license | |
14 | +-- ==================================================== | |
15 | +CREATE PROCEDURE [dbo].[usp_UpdateLicenseModuleStatus] | |
16 | + @LicenseId int, | |
17 | + @ModuleId int, | |
18 | + @ModuleStatus bit, | |
19 | + @Status bit out | |
20 | +AS | |
21 | +BEGIN | |
22 | + | |
23 | + -- SET NOCOUNT ON added to prevent extra result sets from | |
24 | + -- interfering with SELECT statements. | |
25 | + SET NOCOUNT ON; | |
26 | + set @Status = 0; | |
27 | + BEGIN TRY | |
28 | + BEGIN TRANSACTION | |
29 | + if(exists(select * from ModuleToLicense where ModuleId = @ModuleId and LicenseId = @LicenseId)) | |
30 | + begin | |
31 | + UPDATE ModuleToLicense SET Status = @ModuleStatus where ModuleId = @ModuleId and LicenseId = @LicenseId; | |
32 | + end | |
33 | + else | |
34 | + begin | |
35 | + insert into ModuleToLicense(LicenseId, ModuleId, Status) values(@LicenseId, @ModuleId, @ModuleStatus); | |
36 | + end | |
37 | + COMMIT TRANSACTION | |
38 | + set @Status = 1; | |
39 | + END TRY | |
40 | + BEGIN CATCH | |
41 | + IF @@TRANCOUNT > 0 | |
42 | + ROLLBACK TRANSACTION | |
43 | + END CATCH | |
44 | + | |
45 | +END | |
46 | + | |
47 | +GO | |
48 | +SET QUOTED_IDENTIFIER OFF | |
49 | +GO | |
50 | +SET ANSI_NULLS ON | |
51 | +GO | |
0 | 52 | \ No newline at end of file | ... | ... |