wbvardef in connect scripts

42 views
Skip to first unread message

Chris Young

unread,
Apr 26, 2023, 2:24:12 PM4/26/23
to SQL Workbench/J - DBMS independent SQL tool
Thomas,

In Connect script -> After connection is established, I am running
wbvardef -file="c:\abc.txt";
wbvardef abc=abcdef;
wbvardef xyz="1234";
wbvardef -variable=v -query="select @@version";

The messages window shows:
Running statement from connect script: wbvardef -file="c:\abc.txt"
Running statement from connect script: wbvardef abc=abcdef
Running statement from connect script: wbvardef xyz="1234"
Running statement from connect script: wbvardef -variable=v -query="select @@version"

Variables from the -file invocation will be defined and properly assigned in the Statement editor, but variables from the direct assignments do not exist (ie, are not defined).

workbench.log shows only this (and no errors):
2023-04-26 11:17:21 INFO  Variable definition loaded from c:\abc.txt

Is the above intended behavior?

Thanks,
Chris

Chris Young

unread,
Apr 26, 2023, 2:37:02 PM4/26/23
to SQL Workbench/J - DBMS independent SQL tool
I forgot to mention
Build:  129.3
Java: 17.0.7 (64bit)
O/S: Windows 10

Thomas Kellerer

unread,
Apr 27, 2023, 2:16:29 AM4/27/23
to sql-wo...@googlegroups.com
Thanks for the feedback.

I can reproduce the behaviour when "Separate variables per window" is enabled ("General" options). I will fix this.

If you disable the "per window" variables, it works again.

If you do want per-window variables, you can use the use profile variables instead (however they don't support running queries)

Regards
Thomas

Chris Young

unread,
Apr 27, 2023, 9:47:09 AM4/27/23
to SQL Workbench/J - DBMS independent SQL tool
Ah, yes.  I did have "per window" enabled.  I do need the -query case so in the interim I have created a macro that I can run after logging in.

Thanks!

Chris Young

unread,
Jun 5, 2023, 12:15:10 PM6/5/23
to SQL Workbench/J - DBMS independent SQL tool
Thomas,

Thank you for fixing in 129.4 the profile connect script issue when Separate variables per window was enabled.

I'm experiencing, perhaps, a new issue.

I've wrapped my multiple wbvardef (-file and -variable/-query variants) together into a single wbinclude connect script.  The script works as expected within the editor tab resulting in variables being set, but in the profile connect script us case, while I see the output in the Message pane indicating it was executed, none of the variables exist in the Editor/Window.  Is that expected behavior for wbinclude inside the connect scripts (ie, to run but have the variable assignments isolated from the Window)?

Thanks,
Chris

Chris Young

unread,
Jun 5, 2023, 3:45:33 PM6/5/23
to SQL Workbench/J - DBMS independent SQL tool
I played with this some more, and I can't get wbinclude to work the way I was describing above (ie, set the variables for the window).  I'm guessing that I may have run a macro that was running the statements individually thinking I was running wbinclude.

So, perhaps, wbinclude isn't meant to set variables within the editor/window but rather to have a separate, scoped variable environment which goes away once the script ends.  I don't see the expected behavior described in the manual, so please let me know what the intended behavior should be.  If that is the case, then I will revert the connect scripts for my profiles to run the individual wbvardef commands.

Thanks!

Thomas Kellerer

unread,
Jun 5, 2023, 5:22:48 PM6/5/23
to sql-wo...@googlegroups.com
WbInclude is meant to work like that - you just discovered another bug with the new "Separate variables per window" feature :(

Thanks for the feedback.
Thomas
> --
> You received this message because you are subscribed to the Google Groups "SQL Workbench/J - DBMS independent SQL tool" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sql-workbenc...@googlegroups.com <mailto:sql-workbenc...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sql-workbench/0d30e88e-f5ca-4015-9042-37b90dc58d28n%40googlegroups.com <https://groups.google.com/d/msgid/sql-workbench/0d30e88e-f5ca-4015-9042-37b90dc58d28n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages