I am trying to use a variable that I am updating in a loop inside an expression in SSIS. I am going to trying to be as clear as possible. Before to arrive to the last Data Flow Task (where I have a ODBC source), I am getting some values inside the variable (Return) that I am going to use in the [ODBC Source].[SqlCommand], with the second Script Task I could checked that the variable is been updating in the way I need. The problem is that in the Data Flow the expression is taking into account this variable but with the Default value that I have choosen ('').
In the first Script task I am updating the variable:
Dts.Variables["Return"].Value = Dts.Variables["Return"].Value + identif;
So, I do not know if I missed a previous indication or what could be happening with the execution of this control flow
The Variables window will not show you the value of the variable at the end of package execution. You need to set breakpoints and use the local window to "catch" the value of the variable before and after it changes.
Breakpoints Example
I have a package with a single script task.
The code inside is this...
new string strReturn = "NewValue";
public void Main()
{
// TODO: Add your code here
Dts.Variables["Return"].Value = strReturn;
Dts.TaskResult = (int)ScriptResults.Success;
}
The code sets the my SSIS variable equal to NewValue. To catch this variable changing values I will set breakpoints. To set breakpoints, right-click the Script Task and select Edit Breakpoints.
Set a Pre and PostExecute breakpoint. Save and then execute the package. When it reaches the breakpoint, it will pause. The first pause is PreExecute event, just before the script is about to execute. During this pause, you can enter the name of your variable into the locals window.
You will see that the value has not changed yet. Press the continue button to move to the next breakpoint, PostExecute. Now, the Script Task has been executed. Check the local window and you should see that the value has changed!
Notice that throughout each of these the top left Variables window never shows an updated value. It always shows '' . You must use breakpoints to see a variable value changing. Hope this helps you to debug your package!
Related
I am calling a macro using call macro in UiPath Workflow. The concern is some time one of the excels that the macro handles will freeze forever, Causing the macro execution to hang and the process will get stuck in Call macro forever.
Is there some way I can modify the UiPath workflow so that, if the Call macro activity is not completed within 15 minutes, the bot throws an exception?
There is a way to do this, let me try to present it to you:
You will need 3 variables for your solution as per below:
One to store your wait time until exception will be thrown type of TimeSpan
One to declare your start time of your current execution type of DateTime
One to inform if the default wait time of execution was exceeded or not type of Boolean
Then you need to use Parallel activity where on your Excel Application Scope and Execute Macro will run together with a While loop that will constantly compare starting time and your set waiting time. If it will exceed the default time value set, an exception will be thrown. Check the solution example below:
In this case because we surround Parallel Action in Try-Catch block, you need to specify the exception expression in Catches section, since Throw will be overwritten by Catches as per below:
The second option is to do it without Try-Catch then the Throw exception will be displayed, check solution below:
Also you need to modify the Throw action by setting the exception message accordingly as per image below:
Hope this will be helpful.
You can wrap your call macro in a parallel where you in a second branch have a delay and a Throw Exception. The delay should be your desired timeout value, i.e. 15 minutes.
You also need to have a local variable of type boolean as input to the condition property in the parallel. When/if the macro call returns you set this boolean to True which in turn cancels the delay branch.
This way, if the exception is thrown the parallel is exited and the workflow continues. Based on your desired behavior you may want to wrap the parallel in a try-catch.
Answer by #Konstantinos Palaiodimos is in the right direction but the branch 2 is having loop which would continuously execute until maxWaitTime and eventually would throw exception. So to ensure the control goes back to Branch 1(Excel scope) after timeout checking in Branch 2(Do while Loop) a delay need to be added to the Branch 2.
If there is a delay in branch 2 the control will go back to Branch 1 during that delay to check if macro execution is completed or not , if macro is not completed then again control comes back to branch 2 and the cycle continues until maxWaitTime or till the macro execution completes
When the debugger is in break mode, I can't view the value of a variable within the current scope of a "With" block by placing the mouse pointer over the object's property. That is, in the code below, nothing happens when I hover over over ".acctProperty" to find the current value of AcctObject.acctProperty.
With AcctObject
...
Dim xyz = .acctProperty
'''
End With
This is VB.NET in VS2015. Is there a way to accomplish this?
You can just type AcctObject.acctProperty into the Watch window.
If you can't find the watch window - then you can access it by choosing Debug .. Windows .. Watch from the top menu when in debug mode.
So I have seen all the ways to hide the screen updating in excel, what I'm looking for is a data problem, so I WANT to see the screen update. Is there a way to code the screen to update during the macro slowly? I tried the following:
'//////adding screen updating to watch what's happening
Application.ScreenUpdating = True
Application.Wait Now + TimeValue("00:00:01")
'/////
and all I got was screen flicker.
Thanks for being excellent unto me.
What you're after is a better method of debugging your errors. ScreenUpdating property of the Application is not what you want :)
Instead, set a breakpoint in your code using F9, at or before where you suspect the error is happening. If necessary, you can put this on your first line of code (if you literally have no idea where the error happens).
Here is a breakpoint, it's the red/maroon highlighted line:
Then, using the F8 key, you can step through the code line by line.
You can add as many breakpoints as you want. Pressing F5 will execute the code only up to the next breakpoint, then you would have to F8 or F5 to resume execution.
Some additional things to help you debug
Use the Locals window.
This shows you the vairables in scope, and you can click on them to view their properties/etc. As you can see, I have a shitload of variables in a fairly complicated application. I've found the immeidates window is very helpful for Object variables and arrays. Here is what it looks like when I expand an array variable, so that I can see all its contents:
Use the Immediate window to query variables or execute statements outside of your code, this is equivalent to Debug.Print statements. For example, let's check to see if the value of some variable is "9", you can:
?someVar = 9 and then press enter. It will show you True or False. You could query the value directly by ?someVar and it would print the value.
In this screenshot, I am checking the value of a boolean, and it shows me that the value is False. I could also verify this in the Locals window.
The screen updating must be set only once, at the start of the code.
But the Wait you will need to put inside your loop, or spread between your code lines.
I have the following Coffeescript code:
for name, data of statistics
row = document.createElement 'tr'
row.onclick = ->
alert name
However, when I compile and run it (in the context of a large webpage), it alerts the same name, no matter what row I click on. It seems to be remembering the variable, as if it's constant.
What am I doing wrong?
EDIT:
I've discovered the issue, but I'm not sure how to go about fixing it: Javascript/Coffeescript does not evaluate the 'name' variable until the end of the loop is reached.
The functions that you are defining (and assigning to the row's onclick attribute) all have access to the same variable outside that function (name). At the end of the loop, name has one value (the last item in the loop, as you mention), so each of the onclick functions alerts that value.
You can fix this by binding 'name' to a value that doesn't change. This question presents one solution. This question has some useful background that's worth reading.
I am new to vb. When I started to work on this new project in vb.net 2010, I put many breakpoints to try to understand the execution order of the project, only to find it in vain.
Step into command F11 should work correctly according to Step Into Property/Function (F11) doesn't work as expected. But I when I pressed F11, I found the code is jumping from one place to another based on breakpoints, not line by line or step by step.
To give an example, please see the code below
Me.tcData.Alignment = TabStrip.TabControl.TabAlignment.Bottom 'line 1-breakpoint
Me.tcData.Dock = System.Windows.Forms.DockStyle.Fill 'line 2
...
Me.tcData.TabsDirection = TabStrip.TabControl.FlowDirection.LeftToRight 'line 3
Public Property Alignment() As TabAlignment 'The property 1 called by line 1
Get
Return m_Alignment
End Get
Set(ByVal value As TabAlignment)
m_Alignment = value
AdjustHeight()
PositionButtons()
For Each t As TabPage In TabPages
t.Alignment = value
Next
End Set
End Property
Public Property TabsDirection() As FlowDirection 'The property 3 -breakpoint
Get
Return m_TabsDirection
End Get
Set(ByVal value As FlowDirection)
m_TabsDirection = value
SelectItem(Nothing)
End Set
End Property
When I press F11 at line 1, it goes to the property 1. After it returns, when I press F11,it goes to property 3 directly, without accessing the code in line 2 and line 3.
I do not understand why the code is NOT executed step by step by using F11. If I put breakpoingts in line 2, then line 2 is executed.
So it seems to me that the showed execution order is based on breakpoints! So if I put breakpoints at different places, the showed execution order would be different! Thus, it is impossible for me to really understand the execution order.
Thanks!
When you tell it to Step Into, it follows the exact code path. So in order to calculate TabStrip.TabControl.TabAlignment.Bottom in line one, it first has to reference TabStrip, then look up the TabControl property, then look up the TabAlignment property, then-- Here's where it jumps to the property 1 label, right? That's because it has to execute the Get section for the TabAlignment property in your code. Once it executes that, it knows what the reference is, and so it returns that back to the previous level of execution, at which point it can look up the Bottom property. Now, it can assign the value to the Me.tcData.Alignment property.
The same goes for line 3: In order to know where it is assigning TabStrip.TabControl.FlowDirection.LeftToRight to, it has to evaluate the Me.tcData.TabsDirection property, which involves executing your code in the Get section of your TabsDirection property.
So, in short, you are seeing the exact execution path that the code is following, including all the "sub-evaluations" that have to be performed to calculate both the "source" and "destination" properties. Depending on the debugger configuration, it might not show this for system code, but if you set the debugger to be as verbose as possible, it will jump to the Get definition for every property you reference, including system code. There are 5 property lookups for System.Windows.Forms.DockStyle.Fill, just to assign it to a local variable.