Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.80 KB | None | 0 0
  1. -- if we have a branch for the applicant
  2. -- update the relevant Ultra-Staff tables
  3. DECLARE @targetid INT
  4. DECLARE @branchcode VARCHAR(50)
  5.  
  6. IF @appl_id_us > 0
  7.     BEGIN
  8.         SELECT @targetid = @appl_id_us
  9.     END
  10. ELSE
  11.     BEGIN
  12.         SELECT @targetid = @new_applicant_id
  13.     END
  14.    
  15. IF EXISTS(SELECT * FROM dbo.ASEWEB_APPL_BRANCH WHERE appl_id = @appl_id)
  16. BEGIN
  17.     SELECT @branchcode = (SELECT branch_code_us FROM dbo.ASEWEB_APPL_BRANCH WHERE appl_id = @appl_id)
  18.     IF UPPER(@branchcode) <> 'NOT SELECTED'
  19.       BEGIN
  20.         UPDATE t_applicant_details SET DET_OFFICE = CAST(@branchcode AS INT) WHERE APPL_ID = @targetid
  21.         UPDATE dbo.uboT_PR_EMPLOYEE SET Branch_Number = CAST(@branchcode AS INT) WHERE EmployeeNumber = @targetid
  22.         UPDATE dbo.ASEWEB_APPL_BRANCH SET appl_id_us = @targetid WHERE appl_id = @appl_id
  23.      END
  24. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement