You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplified example below, but I have a use case where I want to rollback the transaction on a one time script, only if the outcome isn't as expected. I realize that one time scripts are running in a transaction already. We have scenarios where some of our environmental databases are out of sync due to scripts being manually run outside of Roundhouse on occasion, and I can't always trust the data.
I'm basically saying, if outcome.Count isn't 15, then rollback. Is this possible in Roundhouse, or is there a better way to deal with this?
-- Required variables
DECLARE @Now DATETIME = GETDATE()
DECLARE @Code NVARCHAR(5) = 'ABCDE'
DECLARE @OldCode NVARCHAR(5) = 'XYX01'
-- Checks and balances table variable
DECLARE @Assignments TABLE
(
-- ......
)
-- insert the existing assignment counts
INSERT INTO @Assignments
SELECT .....
-- The rows we are inserting
DECLARE @Regions TABLE
(
-- ....
)
-- there are 15 inserts here
-- the checks and balances at
-- the end should confirm that
INSERT INTO @Regions
VALUES
....
-- Insert these new records
INSERT INTO [Table].......
-- how many assignments does each supplier have now?
UPDATE A SET
FinalAssignments = TotalAssignments
FROM @Assignments A
INNER JOIN (
SELECT ...
GROUP BY ...
-- If we have more than X new assignments for any supplier then something has gone wrong
IF EXISTS(SELECT NULL FROM @Assignments WHERE Assignments > 15)
BEGIN
SELECT 'We have more than 15 added assignments to one or more. Something has gone wrong'
ROLLBACK TRAN
RETURN
END
The text was updated successfully, but these errors were encountered:
Simplified example below, but I have a use case where I want to rollback the transaction on a one time script, only if the outcome isn't as expected. I realize that one time scripts are running in a transaction already. We have scenarios where some of our environmental databases are out of sync due to scripts being manually run outside of Roundhouse on occasion, and I can't always trust the data.
I'm basically saying, if outcome.Count isn't 15, then rollback. Is this possible in Roundhouse, or is there a better way to deal with this?
The text was updated successfully, but these errors were encountered: