Today is one of the days.. the brain stop processing logic
I need to do some batch process.
First I need to check if the position are completed with refrence to a header record.
I do this with a batch: exec sp_BuyersCheckPosition @TransID, @CustomerNr, @PosCheck OUTPUT
If the position is not yet complete, I check if the time since creation has elapse for 5 mins.
I process the batch.. If the condition is not yet met .. I will exit the execution..
Note.. If the position is complete, there is no need to check the time.. But if the position is not complete .. then check if the waiting time of 5 mins has elapse before processing the batch.
IF EXISTS(SELECT CreateDate FROM Customer_H WHERE (TransID = @TransID
AND CreateDate < (select DATEADD(mi, -2, GETDATE())) ))
@TimeCheck = 1
exec sp_BuyersCheckPosition @TransID, @CustomerNr, @PosCheck OUTPUT
IF (@PosCheck = 1 OR @TimeCheck = 0)
Do my Batch thing