I have a package that sends out two emails whenever a control flow element fails. For example, if the ExecuteSQL Task fails, the Package level OnError event handler fires two emails.
Is this a known issue? How do I get around this?
I can do this through database driven scripts, but essentially, I would like to handle the situation on SSIS itself. Thanks for any help.
Keep in mind that event handlers will raise events anytime the triggering action occurs. So, you're not guaranteed to only get one event using an event handler (with a few exceptions of course).
If you want to guarantee only one email then I would recommend not sending email via the OnError event and instead linking a 'Send Email Task' that is part of the control flow and connected to the ExecuteSQL task with a 'Failure Constraint'.
Or, you could also set a user variable equal to true in the OnError event and then send the email based on that with a 'On Completion' constraint mixed with an expression that checks the value of the Error user variable. That way, it doesn't matter how many times the OnError event raises as the task will only run if it was raised at least once.
Related
I have a SSIS package which contain 5 sequence task container and inside that other control flow task. all are running parallel.
i am trying to have all audit and metadata information like package name,task name and current status of task (running,completed or failed.)
The Bigger Problem i feel here is how to handle once the status of the task got changed.
this information i am trying to save in sql table
package name i can get from system variable, how to get current status of Task.
i am trying to store status value like "start","in-progress","end".
May someone please share your thoughts.
Thanks
You can capture the change of a task's state by using SSIS's Event Handlers. To do this, click on the task itself and then click on the Event Handlers tab at the top of the design-time window. This will bring up a blank window with a blue link in the middle of the page as follows:
Before you click on the blue link, select a specific Event Handler that you want to handle:
From here, you can execute specific tasks. For example, you can run an SMTP mail task in the OnError Event Handler to send an e-mail alert regarding a task error. Or, you can run an Execute SQL Task in the OnPostExecute Event Handler to send data to the database once a task has completed.
I think for your specific problem (how to get Run Time for a task), you will need two Event Handlers:
OnPreExecute: Capture the system's datetime value via GETDATE() and write it to a SQL table as SequenceContainerTaskNameStartTs
OnPostExecute: Capture the system's datetime value via GETDATE() and write it to a SQL table as SequenceContainerTaskNameEndTs
Where 'Ts' stands for TimeStamp.
You can then calculate the runtime with the DATEDIFF() function and specify the time interval (e.g., seconds, minutes, hours, etc.). This value can either be stored in a separate field on the table (i.e., SequenceContainerRunTime) or simply generated on-the-fly in a SQL SELECT.
For more information on SSIS's Event Handlers, read here:
Integration Services (SSIS) Event Handlers
I am currently implementing Send Email notification on error in my SSIS package. It currently works. Just want to check if this is the right way of doing it.
If you want to trigger your mail task when any error occurs, consider the "Event Handlers".
This SimpleTask article provides a very good overview of the event handlers
https://www.red-gate.com/simple-talk/sql/ssis/ssis-event-handlers-basics/
SSIS event handlers are the simplest means of turning an SSIS script into a reliable system that is auditable, reacts appropriately to error conditions, reports progress and allows instrumentation and monitoring your SSIS packages. They are easy to implement, and provide a great deal of flexibility.
Sample screen shot:
Using event handler provides some advantage - you need not connect each task's failure. The system will call your event handler for the error.
Also, note there are 2 event handlers of interest:
OnError
OnTaskFailed
https://learn.microsoft.com/en-us/sql/integration-services/integration-services-ssis-event-handlers
OnError event - This event is raised when an error occurs.
OnTaskFailed event - This event is raised by a task when it fails.
One thing to watch out for is that you event handler may be called multiple times depending on the number of errors.
I think there is no standard answer to this question. But here are some of the tips that I am be able to think of.
First, not very sure what kind of plain text you are trying to send out, if they do not have dynamic text body, you could put that send email task in the event handlers right to the Control flow, Data Flow... tab, and put that on error for specific tasks.
Second, I personally do not prefer to use Failure output, you may need to increase the number of MaximumErrorCount so that the package could executed successfully, but sometimes the real error might not be detected because together with error output, the total error numbers is still less than the threshold.
Third, if you are sending the same text, and you will schedule it as a job in SQL Server Agent, you could go to Notifications option page, set the Send Email, basically it will be informative.
Last but not least, the Send Mail task supports plain text only, not any formatting like email coded by html & CSS, if you need to take the formatting into consideration, that might not be your choice, you could use Script task using C# or creating html page by using XML statement from your SSMS and put into a stored procedure, then sent out the html by Database Mail, you will find this tool under Management folder in your SSMS.
I am using ssis event handler to trigger an email whenever an error occured in the entire package(PACKAGE+ONEEROR). Here number of emails triggered is equal to number of errors generated.How can I restrict it to one mail eventhough the same error occured 10 times.
Please suggest....
You have a few options. The problem with setting an ONERROR email at the package level is that it will send an email for each error the package encounters. This gets ugly if you have a deep level transform fail, which will error as it fails back up to the package level.
I suggest that you either:
1) Setup ONERROR events at the task level and remove the package level event. Usually this will be good enough. Most tasks will only have one error to report. Be careful with Data Flows, they can act in a similar fashion as the package level events.
2) Setup some sort of advance logging. I’ve seen this done several ways. I’ve seen some people setup Script tasks to log the errors (at the task level) to a variable, and then send a final email containing the variable in the body (at control flow level). I have also seen people call stored procedures (at the task level and package level) for each error that occurs. The sproc would log errors to the DB and allow the package to continue on to the next step/container. The logged errors can then be dumped into a csv and emailed as an attachment.
If you like your current setup, you can try changing the error properties for each container/task. I haven't ever done this, but I do know you can change the way tasks handle errors! I don't like this option because you would possibly be missing errors (maybe? kind of guessing).
update From another solution - If you want to keep your current email ONERROR and simply prevent certain errors from "bubbling" up and sending emails, you can follow this link to learn how to gracefully handle errors. You could prevent certain tasks errors from reaching your ONERROR event at the package level. good luck.
I'm seeing multiple submissions on a form, presumably because someone is double-clicking a submit button. Is there a good way to prevent this in GAS? I suppose I could set up a global variable via JSON, and use that to determine whether or not to execute the handler, but it seems a bit clunky.
Thanks.
create a client Handler that disables the submit button before the rest of your code is executed.
You can add a client handler anywhere you would add a server handler of any type, and it works entirely on the client without any server roundtrip.
See Serge insas comment below!
I have to modify an Oracle Form but cannot find my way to start.
What is the start up order for a standard form? That is which event, trigger etc will be called at form load, canvas load, etc. I assume that it is When-New-form-Instance but a cannot get it to stop at a break point on the first line of this trigger.
I am getting
FRM-40735 ON_ERROR trigger raised unhandled exception ORA-06508
Which I suspect means I do not have my environment set up correctly but I have done the same as others at this site. So I thought to start with debugging and try to identify which call is failing
PRE-FORM fires before WHEN-NEW-FORM-INSTANCE. Check what's defined in PRE-FORM trigger.
Also, your ON-ERROR trigger is giving a ORA-06508 error, so might want to check what program unit is being referred to in the ON-ERROR trigger
To get a start in trying to find the source of the error, try disabling custom code in forms. If the error does not persist when custom code is disabled, you'll have to start tracing through CUSTOM.PLL to find the source of the issue.