I want to loop through 5 items in SQL SERVER Stored procedure, using CURSOR
1
2
3
4
5
Problem is,
Lets say I am done with the job of 1
When I am at position 2, I got a condition and did some logic, which adds one more item, but I have only 3 more items left in the loop.
How can I make the cursor to run for one more item ie. (from 5 items to 6 items)
EDIT
I am describing one situation -
I have to loop through 5 images
For 1st image, if a logic results to = 1, we perform some operation,
and move to the next image.
For 2nd image, if a logic results to = 2, we add one default image,
and again check the logic result ,
if again logic results to = 2, we add one default image,
and again check the logic result till it become = 1, and then I need to move to 3rd image..
Related
I have an input that generates dynamic select, when placing a value in the input this dynamically adds a select with those amounts of values, for example if the value in the input is 4 in the select it loads me the numbers from 1 to 4 and if I select a value in that select, for example, 2 loads me another select with the numbers from 3 to 4 and so on until reaching the value of 4, it also has a condition that if the highest number is chosen in the first select It would be 4 in this example, it does not generate any additional statements.
Now what I need is that the statements are not generated automatically, as it is doing, is that there is a button for each select and when giving it there is if it generates the other select.
https://codesandbox.io/s/frosty-dawn-c55ux?file=/src/App.js
If I understood correctly, I would add a button from onClick right next to the generated select.
Instead of putting a function on onChange, put it on this new button on onClick.
Here is an example, you initialize the max number in the input then the first Select will be generated.
https://codesandbox.io/s/stack-select-forked-qn212?file=/src/App.js
I'm using React-window - which is a more modern version of react-virtualized - to display a infinite list of images. It works very well with a classic list, but it freezes the ui when used as a grid.
I suspect the reason is that react-window grid does not send back a unique index for each element but a row and/or column index. Long story short, if you display 3 images per row:
row 1 => image 1 = index 0, image 2 = index 1, image 3 = index 2
row 2 => image 1 = index 0, image 2 = index 1, image 3 = index 2
So items are repeated instead of receiving index 4,5 and 6. Has anyone used the library's grid, and if so, how did you manage to retrieve the correct items in the correct columns?
Currently, when I save a multipolygon, I do this by combining all the polygons I have into one string before I save them into one cell. Worked like a charm so far.
However, I'm starting to get bigger and more polygons, which creates huge strings and slows down my merge sp. I would like to know if there is a way to add a polygon to an existing multipolygon. Example: I have two polygons. With the first polygon, I create a new entry and save that one polygon as a multipolygon. Then, I take the second polygon and add it to the existing data, updating the already existing record.
INSERT INTO MyTable
VALUES ('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)))')
Pseudo code:
UPDATE MyTable
SET PolygonData.Append('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))')
WHERE Id = 1
Note: The column PolygonData is of the Geography data type.
Is it possible to append polygons like that into an existing multipolygon, without reading out the entire data and stitching it together?
I have a Table called Trip where the users can create trips, and on the edit screen I have a button that the users can click on it and create Legs for that selected trip. my question is how do I make a field in the TripLegs domain auto increment?
so lets say the user creates four trip legs, so the stop number field "the one I wanted to auto populate" would be
1
2
3
4
if the user goes back and delete Trip leg 2 so how do I change the stop number in the rest three legs to
1
2
3
instead of
1
3
4
I have to agree with Vahid's comment on the original question. My preferred approach would be to dynamically set that value as a transient value on the domain after I sorted the collection by some criteria.
If you wanted to maintain the same sort order every time based on which Leg was created sequentially, you could add a 'Created_Date' column to your table and sort based on that value when you get the list.
Alternatively, if you would really like to store the stop_number value (which there are plenty of reasons why you might want to) you might want to consider the following approach:
Override the default Delete action for TripLegs:
class TripLegController {
def delete = {
def tripLegId = params.tripLegId as Long
def tripLeg = TripLeg.get(tripLegId)
def otherLegs = TripLeg.FindAllByTripAndIdNotEqual(tripLeg.trip, tripLegId, [sort: 'stopNumber', order: 'asc'])
tripLeg.delete(failOnError: true)
def stopNum = 1
otherLegs.each{leg ->
leg.stopNumber = stopNum
leg.save()
stopNum++
}
}
}
I need some help figuring out how to accurately display the labels in a stacked chart in SSRS; I need a single represenation of the upper stack in the below chart.
The chart itself has two states, it can either be based on red or green data, both are in the same data source.
At the moment the chart looks like this (this is based on green data):
As you can clearly see both the labels inside the chart and the legend is absolutely cluttered. The idea is to have a legend where we have two items (Late issues and Not finished issues); one that displays any non-finished issues and one that displays any non-finished issues that are outside the estimated due-date.
For reference: The above chart should have 1 non-outstanding issue and 5 outstanding issues (3 Ongoing and 2 Open, see below for further info about stages).
Inside the chart we want to have a numerical respresentation of above requirements. Basically a number representing the outstanding issues and one that shows any non-finished issues.
This is what a red representation looks like:
At this point I'm not sure what could be wrong anymore. As mentioned they both run on the same dataset, but with slightly different values.
The red tracker has a simple True/False value that it runs most of its data from whereas the green tracker has a numerical representation of three values (5-7). Where the data it represent is: 5 - Open, 6 - Ongoing, 7 - Closed.
I've attempted to only get the green data both when the series is either of the three above mentioned numbers, but also when it's only getting anything that is un-closed (5,6 but not 7).
This is the code to set the labels for the maroon part of the chart (it's only a workable snippet.):
IIF(Count(IIF(Fields!Outstanding.Value = 1 AND
Fields!TRK_TrackerStatus_LKID2.Value <> 7, 1, Nothing)) = 0, "",
Count(IIF(Fields!Outstanding.Value = 1 AND
Fields!TRK_TrackerStatus_LKID2.Value <> 7, 1, Nothing))))
Basically what it does is checking if there are more than 0 items that are outstanding and that aren't finished (are not 7). If there are more than 0, it sets the label. If there are 0 counted items, the label should be the empty string.
I think what you are wanting to do is group your Series data based on a status number. You can either do this as a case statement in your dataset query or you can use an expression in your Series Group:
The expression I have used there is as follows:
=switch(Fields!Status.Value = 5, "Group 1", Fields!Status.Value = 6, "Group 2", Fields!Status.Value = 7, "Group 2", TRUE, "Group 3")
This esentially assigns a grouping value to your data based on the values in the field. In this case, a Status of 5 becomes Group 1, a Status of 6 or 7 becomes Group 2 and all other values become Group 3 just to ensure bad data is obvious on the report.
What this does is takes the chart as it would be displayed with the raw data (On the left) and turns it into what I think is how you want to see it (On the right):
You will need to apply the same logic to your chart labels as well. For this reason I would recommend you add a column to your original SQL script that does this grouping for you, so you only have to make changes once.