0% found this document useful (0 votes)
19 views

Object: Storedprocedure (Acc) - (PR - Documentscleardateupdate) Script Date: 06/13/2012 10:37:13

This stored procedure updates the clear date for documents based on certain criteria. It takes a transaction GUID as a parameter. It checks the document's clear days and whether the bank is owned, and increments the clear days if not owned and the subtotal is under $300. It then updates the clear date field on matching documents in the database and returns the current date.

Uploaded by

Dai Castellano
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Object: Storedprocedure (Acc) - (PR - Documentscleardateupdate) Script Date: 06/13/2012 10:37:13

This stored procedure updates the clear date for documents based on certain criteria. It takes a transaction GUID as a parameter. It checks the document's clear days and whether the bank is owned, and increments the clear days if not owned and the subtotal is under $300. It then updates the clear date field on matching documents in the database and returns the current date.

Uploaded by

Dai Castellano
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

USE [alliance] GO /****** Object: StoredProcedure [acc].

[pr_DocumentsClearDateUpdate] Date: 06/13/2012 10:37:13 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Script

-- exec [acc].[pr_DocumentsClearDateUpdate] '12EB1FE2-43F7-4AF1-BB58191332D8DD29,0B135EB0-A90C-4E4F-8FFB-5942C9575603' ALTER PROCEDURE [acc].[pr_DocumentsClearDateUpdate] @txnGUIDs uniqueidentifier AS BEGIN TRY BEGIN TRAN DECLARE @clearDays int DECLARE @isOwn bit

SET @clearDays = (select clearDays from acc.Documents where txnGUID = @txnGUIDs) SET @isOwn = (SELECT b.isOwn FROM acc.Documents d INNER JOIN BanksRouting br ON br.RoutingNumber = d.RoutingNumber INNER JOIN Bans b ON b.BankGUID = br.BankGUID) WHERE d.txnGUID = @txnGUIDs)

IF((select subtotal from acc.Documents where txnGUID = @txnGUIDs) < 300) BEGIN IF (@isOwn = 0) BEGIN @clearDays = @clearDays + 1 END END ELSE
UPDATE d SET d.clearDate = @clearDays FROM [acc].[Documents] d join dbo.fnGUIDList2tbl(@txnGUIDs) g on d.txnGUID = g.GUID join acc.PaymentMethod as p on p.paymentMethodGUID = d.paymentMethodGUID join acc.AccountDraftCheck as ac on ac.ReceivedPayTxnGUID = d.txnGUID join acc.BankRouting as br on br.routingNumber = ac.routingNumber join acc.Bank as b on b.bankGUID = br.bankGUID WHERE p.name = 'Draft Check' or p.name = 'Check' COMMIT TRAN END TRY

BEGIN CATCH

DECLARE @ErrorMessage NVARCHAR(4000); DECLARE @ErrorSeverity INT; DECLARE @ErrorState INT;

SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE();

RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)

ROLLBACK TRAN

END CATCH

SELECT GETDATE() as Today

You might also like