I was trying to put if condition in my store proc ,it throws error. I know am doing wrong some where,can some one guide me please
Here what am trying to achieve is ,when ever i do update,i will check the existing record and get the "ClassValue" and check the parameter am getting if both are not equal then i will update "ClassValue" ="01" if not then i will pass the parameter.
Am not sure i miss something in my If condition look like
CREATE PROC [dbo].[InsertEmployee]
IF NOT EXISTS (select employeeno from Phone where employeeno = @EmployeeNo and PhoneNumber = @PhoneNumber)
DECLARE @CONTEXT_INFO varchar(100)
SELECT @CONTEXT_INFO = COALESCE(CONVERT(VARCHAR(128), CONTEXT_INFO()), CURRENT_USER)
Declare @Level deceimal(18,2)
@Level = Ad.ClassValue
WHERE Ad.Employeeno= @EmployeeNo
update [Employee] set ClassValue= '01', UpdatedBy = @CONTEXT_INFO where employeeno = @EmployeeNo
update [Employee] set ClassValue= ClassValue, UpdatedBy = @CONTEXT_INFO where employeeno = @EmployeeNo
I will insert.