[go: up one dir, main page]

0% found this document useful (0 votes)
5 views2 pages

classroom_user_insertion

Download as txt, pdf, or txt
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 2

USE [OCO_DEV]

GO
declare @company_id int,@center_id int,@location int ,@UsgOrgId INT,

@userName varbinary(800),
@password VARCHAR(64),
@email varbinary(800),
@fName varbinary(800),
@lName varbinary(800),
@roleId Int,
@companyroleId Int,
@userStatus SMALLINT,
@logUserId VARCHAR(100),
--@locations varchar(2000),
@deletedLocations varchar(2000),
@isCustomerSupportAdminUser int,
@PASSWORD_ENR_TYPE smallint,
@Employee_Id varchar(50) ,
@userId int =0;

set @company_id=34297;
set @center_id=1;
set @UsgOrgId=@company_id;
set @location=54860;
set @userName=CAST('classcanada' AS VARBINARY(800));
set @password='6f4ff77e735226a2b9f77336993cb4c115fd8c9fd77f1110443f3c7a4c791bf2';
set @email=CAST('classcanada@1core-test.com' AS VARBINARY(800));
set @fName=CAST('class' AS VARBINARY(800));
set @lName=CAST('canada' AS VARBINARY (800));
set @roleId=6049;
set @companyroleId=46114;
set @userStatus=1;
set @logUserId=291114;
set @PASSWORD_ENR_TYPE=2;
set @isCustomerSupportAdminUser=0;
set @Employee_Id=0;

INSERT INTO USER_DETAILS


(
User_Original_Id, User_Email,[Password],User_Status,

FirstName,LastName, user_email_Address,

CreatedBy,CreatedDttm,ModifiedBy,ModifiedDttm,
isCustomerSupportAdminUser, passwordEnrType, LoginAttemptCount,

Employee_Id
)
VALUES
(
@UsgOrgId,@userName,@password,@userStatus,

@fName,@lName,@email,
@logUserId,getdate(),@logUserId,getdate() ,
@isCustomerSupportAdminUser,@PASSWORD_ENR_TYPE,0,
@Employee_Id
)
set @userId = (SELECT SCOPE_IDENTITY())

-- role insertion
INSERT INTO dbo.USER_ROLE
([user_id],company_app_role_id,created_by,created_dttm,updated_by,updated_dttm)

values ( @userId ,
@companyroleId,
@logUserId,
getdate(),
@logUserId ,
getdate())

-- USER_LOCATION insertion

INSERT INTO dbo.USER_LOCATION (location_id,[user_id],created_by,created_dttm)

values (@location, @userId, @logUserId , getdate() )

Declare @Tempclass AS TABLE


(
Child_Type_Id INT
)
INSERT INTO @Tempclass (Child_Type_Id) (
select Child_Type_Id from [Child_Type_Details] WHERE company_id = @company_id and
center_id = @center_id
and CLRM_STATUS = 1 )

-- user classroom insertion


insert into user_classroom
(User_Id,company_id,center_id,CLASSROOM_ID,created_by,created_dttm)
select @userId,@company_id,@center_id,cr.Child_Type_Id,@logUserId,GETDATE()
from @Tempclass cr where not Exists
(select ur.CLASSROOM_ID from user_classroom ur where ur.center_id=@center_id and
ur.CLASSROOM_ID=cr.Child_Type_Id and ur.User_Id=@userId )

You might also like