SSIS and reporting success after for loop retry - sql-server

Given the For Loop retry scheme below (working), how can I make the package return success versus failure? I've seen some tantalizing clues such as a task or package's ForceExecutionResult = Success but not sure how I can incorporate that into my process (I have many just like the below). If indeed setting ForceExecutionResult is an answer, do I set this using a ScriptTask or Expression? Is that property available in an obvious way, other than from the properties page? Thank you.
Additional note/explanation: I need to conditionally return success or failure based on the number of retries. A failure, retry, and success is success. In my For Loop, three retries is a failure. I can't arbitrarily set ForceExecutionResults = Success.

The resolution or at least one approach was to assign the On Error Handler's variable Propagate to True or False, using the User variables I was already using for the For Loop try scheme.
#[System::Propagate] = #[User::CountryIncrement] == #[User::RetryCount] - 1
You put that (above) in an Expression Task in the Task's On Error event handler. That way when the error retry count has been reached, the error will propagate up to the parent and correctly report failure. If it retried once, say, and subsequently succeeded, Propagate will be False and not bubble up. The Tasks Job Step will report success.

Related

x.stop_sequences() is causing this UVM FATAL Item_done() called with no outstanding requests

x.stop_sequences() is causing this
UVM FATAL Item_done() called with no outstanding requests. Each call
to item_done() must be paired with a previous call to get_next_item()
Can someone tell me how to use stop_sequences while making sure the driver is inactive?
I don't think there is any built-in mechanism; you have to write the code yourself. Basically, you need to implement a reset or interrupt mechanism in your driver. Here is a skeleton idea:
task run_phase (uvm_phase phase);
forever begin
#(posedge <ENABLE INPUT>);
fork
<DO DRIVERY THINGS>;
join_none
#(negedge <ENABLE INPUT>);
disable fork;
end
endtask: run_phase
In addition to #mathew-taylor's suggestion, you may need to also consider the monitor, since it will need to discard partially assembled data collections.
If you have a reactive driver, this gets even trickier. It would be prudent to provide an boolean validity attribute in your transactions. Construction would set it to true (1'b1). If responses are outstanding upon reset, send all the outstanding responses after setting the validity field to false (1'b0). This will keep the sequencer from jamming. Any consumer of transaction data would then need to examine the validity. To simplify, you could build in the check via accessor functions and make all attributes local. This would also work on the monitor.

Fail entire SSIS Package in case of Exception

I have a SSIS package with lots of containers and logic. I am running an additional task (which I want to run independently) let's say it acts as an Event Listener. When this separate task is errored, I want to error out the entire package. I thought, it should work by default but to my surprise, it's not:-
I have tried setting both FailPackageOnFailure & FailParentOnFailure properties on both the parent container & the child container but it's not working.
I was about to ask exactly the content of your last comment.
Failure of one piece of a package won't make another, unconnected piece stop executing. Once the executing piece is done, the package will fail, but Sequence Container 3 has no way to know what's happening in Sequence Container 2.
Which, honestly, is what we want. If Sequence Container 3 is doing DML, you could leave your data in an unfortunate state if an unrelated failure elsewhere in the package suddenly made everything come to a screeching halt.
If you don't want Sequence Container 3 to run if Sequence Container 2 fails, then just run a precedence constraint from Sequence Container 2 to Sequence Container 3, #3 won't execute until #2 succeeds and the Execute SQL Task succeeds.
I completely agree with Eric's answer. Let me explain to you why raising a flag on error won't work.
I redesign the package so it includes the flag check.
Let's say we have a success flag as user variable which is by default False.
Now we set this variable as True at the end of sequence 2 execution marking the success of all the other tasks in that sequence.
The second part is put into a for loop which runs only once(if at all). It checks if the success variable is true and only then run the inner tasks. It looks like below:
The problem is, the success variable check at the start of the for loop will always have the inital value which is false(because it runs in parallel with seq 2 and doesn't wait till seq 2 ends). Hence the second part is never executed. Now change the initial value of success variable to true and run the package again. Play by disabling the error prone tasks and run the package. You will understand how it works.

Report SSIS success when loop fails

I have a package that has a loop in it, that loops through a few connections. Each iteration through the loop is a new connection. The problem is though that sometimes these connections are down at package run time. So I've added an on error, send us an email notification, and then continue with the loop.
This works fine, using the Event Handlers and changing the Propagate value to False. But the issue is, if a connection fails, it will finish the loop, but report the entire package fails. This is an issue because inside a job in SSMS, it will stop the job after that package is complete, and report it failed, when it really did not.
Is there a way to have the package report success even if this loop kicks out the failed e-mail? I don't want it "Continue to next step on fail" because there are other parts to that package that could legit fail, and need to be notified on.
EDIT:
Here are screen shots of what I'm doing. Inside the loop there is a dataflow task, the first dataflow has the connection that sometimes fails. When it does, it triggers the email task to notify us, then will continue with the loop.
Unfortunately the FailPackageOnFailure is already set to false.
On the task that fails (or its parent container if applicable), change the value of FailPackageOnFailure to false.
If you are doing this to a task in a loop, you may want to consider whether you also need to set FailParentOnFailure to false as well.
EDIT: If none of your tasks or containers are causing the package to fail with FailPackageOnFailure=true, then probably you are setting the package to fail in a script. Maybe in your event handlers you are keeping a count of errors, and then at the end of the package you are setting the package state to failure if the error count <> 0.
Examine all the points at which you could be setting the package to fail, either through a script or through the FailPackageOnFailure property.
You can fake the execution result to success by setting the property ForceExecutionResult to Success (Default value of this property is None) for the Foreach Loop Container.

$this->query callback in CakePHP

I need open a transaction, and wait the return for do commit or rollback.
But, how can I get return (true/false - not exception or any "break process") of this query?
$this->query('update checks set discount = 100 where check_num = 3001');
In my tests, when an error occurs, it stops the whole process and returns an exception.
I do not want it, just want to know: has successfully executed or error? (true / false)
What mark said in the comments seems accurate, an updateAll() call would seem more appropriate to achieve what you want. If you ever find yourself in a situation where you actually do need transactions, there are examples on how to achieve that in the documentation as well.

Can an ActiveX Script (DTS) return complete instead of success or failure?

An ActiveX Script in a DTS package can return DTSTaskExecResult_Success or DTSTaskExecResult_Failure. Is there a way to indicate that it is not a success without failing the entire package? We'd like it to keep going, but in a different direction. The options for a path are Success, Failure, and Completion, but it appears the only return values for the ActiveX Script are Failure and Success. 'DTSTaskExecResult_Completion' isn't right. What is?
(The solution we're probably going to pursue is modifying this to SSIS, but I wanted to know if it was possible in DTS.)
Try setting the DTSTaskExecResult_Retry return value; it tells you that it failed, but doesn't failout completely?
Edit: sorry it is : DTSTaskExecResult_RetryStep
FYI: ActiveScriptTask objects have full access to the GlobalVariables collection, which provides a way to share information across tasks.
As far as I know, when using the ActiveX DTS Component, your options are limited to Success/Failure. :(
-Shaun
Yes, the options are limited to Success/Failure.
You can also use RetryStep option, but to do what? This option just repeat the step and the DTS never end.
The option that I use, is to use Success result, always.
But previously to set the result, I do my checking, and if I don't want to execute the next step, just set the task (the next task) as Completed.
By this way, the next task is not executed and you succeed in your purpose.
Sample:
Set oPackage = DTSGlobalVariables.Parent
If HasRows = 0 Then
oPackage.Steps("DTSStep_DTSExecuteSQLTask_1").ExecutionStatus = DTSStepExecStat_Completed
End If
Main = DTSTaskExecResult_Success
Hope this can help to anyone.
Regards,

Resources