You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_creditLimitReset] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_creditLimitReset]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_creditLimitReset] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. CREATE PROC [dbo].[proc_creditLimitReset]
  12. AS
  13. SET NOCOUNT ON
  14. SET XACT_ABORT ON
  15. BEGIN
  16. DECLARE
  17. @today DATETIME = DATEADD(DAY,7,CONVERT(VARCHAR, GETDATE(), 101)),
  18. @lastBgId BIGINT
  19. IF OBJECT_ID('tempdb..#temp') IS NOT NULL
  20. DROP TABLE #temp
  21. SELECT cr.agentId INTO #temp
  22. FROM dbo.creditLimit cr WITH(NOLOCK)
  23. INNER JOIN dbo.bankGuarantee bg WITH(NOLOCK) ON cr.agentId = bg.agentId
  24. WHERE bg.expiryDate < @today
  25. AND ISNULL(bg.isDeleted,'N') <>'Y'
  26. AND ISNULL(bg.isActive,'Y')<>'N'
  27. AND ISNULL(cr.limitAmt,0) > 0
  28. UPDATE dbo.creditLimit SET
  29. limitAmt = '0',
  30. topUpToday = 0
  31. FROM creditLimit cr,
  32. (
  33. SELECT DISTINCT agentId FROM #temp
  34. )t WHERE cr.agentId = t.agentId
  35. END
  36. GO