Using cursor to execute one object at a time.#9
Merged
henrikoppen merged 8 commits intomainfrom May 15, 2024
Merged
Conversation
dss-vipps
approved these changes
May 3, 2024
dss-vipps
suggested changes
May 3, 2024
dss-vipps
reviewed
May 8, 2024
migrations/0002.sqlcode.sql
Outdated
|
|
||
| open @curVFP | ||
|
|
||
| while 1 = 1 |
Contributor
There was a problem hiding this comment.
This will loop forever, then there's an error , and this probably crashes and the rest doesn't execute.
You should instead check @@fetch_status. This should do the trick:
fetch next from @curVFP into @sql;
while (@@fetch_status = 0)
begin
exec sp_executesql @sql;
fetch next from @curVFP into @sql;
end
dss-vipps
reviewed
May 8, 2024
migrations/0002.sqlcode.sql
Outdated
| where t.schema_id = @schemaid; | ||
|
|
||
| open @curT | ||
| while 1 = 1 |
dss-vipps
reviewed
May 8, 2024
migrations/0002.sqlcode.sql
Outdated
| fetch next from @curT into @sql; | ||
| while (@@fetch_status = 0) | ||
| begin | ||
| fetch next from @curT into @sql; |
Contributor
There was a problem hiding this comment.
This will skip dropping the first item; you need to change the order of executesql and fetch next from here
dss-vipps
reviewed
May 8, 2024
migrations/0002.sqlcode.sql
Outdated
| fetch next from @curVFP into @sql; | ||
| while (@@fetch_status = 0) | ||
| begin | ||
| fetch next from @curVFP into @sql; |
Contributor
There was a problem hiding this comment.
Same problem as below; first loop iteration you fetch 2 items before doing any execution..
dss-vipps
approved these changes
May 15, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See this slack thread: https://vippsas.slack.com/archives/C04ECT3856Y/p1714463184441569