Execute current statement where the cursor is

Hi aoeusnth,

Thanks for your suggestions, we will review them for future releases. Right now we are coming closer and closer to 6.0 release which is planned for early June, so I hope you understand we will not be considering 5.8.2 release.

and finally in regards of execute-current-statement for selection - toad will execute only selected part of the script, even if it’s within one statement.

Hi Valentine,

Thanks for the update. I didn’t realize 6.0 was coming so soon: of course that would be preferable to a 5.8.2 release.

I would just like to reiterate the usefulness of the semicolon as an execute-current-statement delimiter. Line breaks are only useful for extremely simple queries, Go for broader queries: semicolons address that sweet middle ground where queries are not trivial but objects like variables remain open. This is especially wonderful for query building and debugging.

Also, we have both MySQL and SQL Server databases going, and in Toad for MySQL (and SQL Browser, in fact) execute-current-statement obeys semicolons. Consistency would be great for us :slight_smile:

Put another way: if execute-current-statement on semicolons and obeying tab orders are implemented, my entire group will immediately move to Toad (back to Toad for some of us). * That’s* how important these two functionalities are to us.

Actually line breaks are not used as statement separators. We currently deep parse entire script to split it into statements, so it will be always accurate, you’ll get current statement regardless of how many lines it occupies and is there other statements on same line on not. Is it what you are interested in? If no, could you please give some T-SQL example of desired behavior.

In regard to Toad for MySql I should say that this new behavior is the most consistent across platforms, as in MySql you can’t omit semicolon, you’ll instantly get a syntax error. So in MySql F9 always executes current (only one) statement. The same now for SqlServer, only current statement will be executed.

Indeed, what you describe sounds like it could work for us. We will wait patiently for the next beta!

  • KJ


Apologies, I completely neglected to send you an example. I think what you describe addresses our needs, as our requirements are very docile. Take the following two statements in the same Toad tab:

TOP 100 *
FROM HappyPlace;

TOP 100 *
FROM SadPlace;

If my cursor is anywhere in the second statement, I expect execute-current-statement to run only:

TOP 100 *
FROM SadPlace;

If I select the entire two statements, I expect two results set in the usual vertical arrangement.

Finally, if I leave out the first semicolon, I expect Toad to throw up an error.

That’s it!

  • KJ

Thank you for the examples. Yes, if the cursor is anywhere in the second statement F9 will now execute only it (unlike previous behavior), and if you select both of them you’ll get two results (just as it already works).

In regard to the omitted semicolon, there will be no error as it’s normal for SqlServer, you‘ll still get correct result from the statement where the cursor currently is. As I mentioned above now statements will be extracted correctly even if there are no delimiters at all.

We are about to publish next beta drop about the middle of next week, so you’ll be able try it out very soon :slight_smile:

Gotcha, sounds all good, thanks for the clarifications. Good luck on your next beta drop!

Execute-current-statement in today’s beta looking good, thanks!

Problem: if my cursor is in the second (complete) statement, Toad won’t execute:

SET @aoeu = ;

SELECT * FROM Currency;

I know the first statement is incomplete, but I expect the second statement to run regardless if my cursor is in it.

I guess this is the true meaning behind “obeying semicolons.” Hopefully this will be easy to address.

Thanks for your time and consideration.

  • KJ


We need to discuss possibility of such behavior with our parser team. We’ll try to keep you in touch on any updates. I’ve created CR 109829 to track down this issue.

Thank you very much!

Possibly related to parsing as well: if the semicolon is on its own line with a comment immediately preceding it, the Messages tab is always displayed rather than the Results tab after running execute-current-statement. For example:

– Test