dbo.EC_UpdateUser.StoredProcedure.sql
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
USE [AIADatabaseV5]
GO
/****** Object: StoredProcedure [dbo].[EC_UpdateUser] Script Date: 02/06/2018 10:49:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ===================================================================
-- Author: Magic
-- Create date: 27-May-2009
-- Description: To update record into AIAUser,License and LicenseSubscriptionDetail table
-- ===================================================================
CREATE PROCEDURE [dbo].[EC_UpdateUser]
-- Add the parameters for the stored procedure here
@sLoginID varchar(50),
@sAmountPaid money,
@sAmountPending money
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
--SET NOCOUNT ON;
DECLARE @iLicenseId varchar(20)
SET @iLicenseId = (SELECT DISTINCT License.Id FROM AIAUser
INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId
INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
INNER JOIN License ON LicenseToEdition.LicenseId = License.Id
WHERE AIAUser.LoginId = @sLoginID)
-- Update the LicenseSubscriptionDetail table for the supplied LoginID
UPDATE LicenseSubscriptionDetail SET AmountPaid = @sAmountPaid, AmountPending = @sAmountPending
WHERE LicenseId = @iLicenseId
--Update the License status to Active for the LoginID
UPDATE License SET IsActive = 1 WHERE Id = @iLicenseId
--Update the AIAUser status to Active for the LooginID
UPDATE AIAUser SET IsActive = 1 WHERE LoginId = @sLoginID
END
GO