A problem in executing SQL scripts #2309
Closed
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.
The reason why I raise this problem is that I encounter a business scenario in the company. I use mysql. I need to execute the SQL script during the running of the program. The SQL script creates databases, tables, stored procedures, functions and views, but errors often occur during the execution. The main reason is that the splitters cannot be handled uniformly when parsing SQL, Here I give an example.
Let's take a look at this example. At present, the default separator is ";", This is effective for the above operations such as creating a database, but it is not allowed to execute the following stored procedure. Therefore, I added an attribute to expand its function. After testing, after setting this attribute, the program can execute the whole SQL script normally. If this attribute is not set, there will be no impact on the original function. Thank you