vscode-db2i icon indicating copy to clipboard operation
vscode-db2i copied to clipboard

Question... Run all/ Run from Selected/ Run Selected...

Open rogersonra opened this issue 2 years ago • 2 comments

I checked the documentation and issues and didn't see this discussed/mentioned. In Run SQL Scripts we had Run All/From Selected/Selected. Unless I've missed it this is not available in the db2i extension.

Is this going to available?

Also, in Run SQL Scripts in Edit->Preferences->General->Run Options we had Highlight next statement after 'Run Selected'. Is this going to be available? With this I could repeatedly press Ctl-R to run multiple statements rather than having to cursor down after each statement.

BTW, GREAT JOB...

Thanks,

Rob

rogersonra avatar Apr 17 '24 16:04 rogersonra

Thanks for submitting this request. Others have also asked for these features, so we recognize the value. We will consider adding in a future update.

davecharron avatar Apr 17 '24 19:04 davecharron

Thanks Dave, I didn't see any other mentions.

Thanks,

Rob

On Wed, Apr 17, 2024 at 3:02 PM Dave Charron @.***> wrote:

Thanks for submitting this request. Others have also asked for these features, so we recognize the value. We will consider adding in a future update.

— Reply to this email directly, view it on GitHub https://github.com/codefori/vscode-db2i/issues/226#issuecomment-2062007896, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXLPJF7TXMXOEE7LFBZANTY53BOBAVCNFSM6AAAAABGLV2FGGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRSGAYDOOBZGY . You are receiving this because you authored the thread.Message ID: @.***>

rogersonra avatar Apr 17 '24 22:04 rogersonra

So here's the plan: we are not going to re-implement Run all, Run from selected or Run selected, as Notebooks can already do all of this with a much better UI.

You can use Notebooks today with Db2 for i, and there is an option to open your current SQL document as a Notebook under the play button.

We do need to add the following:

  • stop support in Notebooks
  • make sure prefixes from statements are handling when opening to notebooks from SQL
  • new Run All in Notebook option in Play button
  • new Open selected in Notebook option in Play button
  • limit the rows out in the cell when using Run all
  • new section in the docs: Running all or selected statements

worksofliam avatar Mar 15 '25 13:03 worksofliam

Okay perhaps a change of plan.

@julesyan and I had some discussions about it and she uses RSS for this feature a lot, and @forstie said this to me:

For run from, I only care about the last results

This is important to know. If this is true, we won't show the result of any statement but the last. This means we only need to call setScrolling once, which has been the biggest blocker of this feature. For every statement being executed, we can just call query on the job, other than the last, where we call setScrolling.

New plan if we go down the re-implementation route:

  • New function called runMultipleHandler which parses the document and determines which groups to run (either via selection or all if no selection). This function probably calls runHandler
  • runHandler to have a new mode for execute, which means execute, await and don't return a result to the UI. Perhaps we store the result somewhere
  • Consider how csv, cl, and other prefixes will be supported
  • New buttons to Run all and Run selected. Perhaps Run all shows when there is no selected and Run selection shows when there is?
  • Add support for stop in runMultipleHandler
  • Stretch goal: perhaps we use the comments API to shows the results for static execution results?

worksofliam avatar Mar 15 '25 14:03 worksofliam

I had a chance to test this today. Run all statements and Run statements from cursor work as expected. But I'm not sure on the Run selected statements. Let's use my previous example (Thanks Liam for fixing this so quick)😊

DROP TABLE IF EXISTS testlateral

CREATE TABLE testlateral (
  id int,
  phone1 int,
  phone2 int,
  phone3 int)
;
INSERT INTO testlateral
VALUES (1, 1111111, 1222222, 1333333),
       (3, 3111111, 3222222, 3333333),
       (2, 2111111, 2222222, 2333333);

SELECT * FROM testlateral;

If I Run all statements It does all...DROP, CREATE, INSERT and SELECT. If I then run just the DROP and position my cursor on the CREATE and Run statements from cursor the CREATE, INSERT and SELECT are run as expected. If I then add stop; after the CREATE statement and Run all statements it does the DROP, CREATE and stops. Everything is EXCELLENCT to this point.

But if I now select/highlight the INSERT and SELECT and Run selected statements I was expecting both the INSERT and SELECT to run. But only the INSERT runs.

I'm not sure if this is expected behavior and I misinterpreted. If so, maybe the name should be changed to Run selected statement (singular).

Other than that GREAT JOB😊👌! This is very useful when running scripts for testing data.

Thanks,

Rob

rogersonra avatar Mar 30 '25 16:03 rogersonra

Hi Rob, I've tried every way I can to recreate this issue and have been unable to recreate what you describe. Could you capture a screen cap of your VS window just before you choose 'Run Selected'? Thanks, Scott

forstie avatar Apr 01 '25 13:04 forstie

Hi @forstie , I tried to duplicate the issue this morning and it no longer happens. All the Selected statements run and stop on the last Selected statement.

Perfect 👌

rogersonra avatar Apr 02 '25 12:04 rogersonra