Re: H2 Console - execute a single statements

291 views
Skip to first unread message

Noel Grandin

unread,
Jul 12, 2012, 8:11:47 AM7/12/12
to h2-da...@googlegroups.com, darc
Unfortunately it doesn't support anything like that at the moment.

Patches welcome :-)

Look in file src/org/h2/server/web/res/query.jsp

On 2012-07-12 12:01, darc wrote:
> Hi,
>
> While working in H2 console I often have multiple statements. If I
> press Ctrl+Enter, then it will execute all statements. Is there a
> shortcut or some other way to execute a single statement?
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/do2RPPixl7AJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.


Thomas Mueller

unread,
Jul 12, 2012, 1:01:52 PM7/12/12
to h2-da...@googlegroups.com
Hi,

Do you mean, you have entered multiple statements, but only want to execute the one where the cursor is? Or execute the selection?

Is there a tool that does this already?

Regards,
Thomas

Thirion

unread,
Jul 13, 2012, 3:53:51 AM7/13/12
to h2-da...@googlegroups.com
SquirreL SQL does that.  Works really well too.

I guess for JSP pages you could add something like this to get the current cursor index:

       <script type = "text/javascript">
            function showCursorPos(myField){
                if (myField.selectionStart || myField.selectionStart == '0') {
                    alert('Cursor is on index ' + myField.selectionStart);
                }else{
                    alert('dunno');
                }
            }

        </script>
        <form name = "myform">
            <textarea name = "txtQuery" rows = "10" cols = "50">Blah blah, fishpaste</textarea>

            <br><br>
            <input type ="button" value="Get Cursor Index" onclick="showCursorPos(document.myform.txtQuery )">
        </form> 

You can then search backward until you either reach the beginning or an empty line and use that as the start index, and search forward until you either reach the end or an empty line as the end index.  If the browser doesn't support the syntax, just use the current behaviour.

I quickly tested this and it gave me the correct index using Chrome, IE and Firefox.

Noel Grandin

unread,
Jul 13, 2012, 3:56:11 AM7/13/12
to h2-da...@googlegroups.com, Thirion
Would be better to simply execute the current selection, whatever it is.
So just take the string from field.selectionStart to field.selectionEnd
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/tpx2IM-l64AJ.

Thomas Mueller

unread,
Jul 13, 2012, 12:54:31 PM7/13/12
to h2-da...@googlegroups.com
Hi,

> Would be better to simply execute the current selection, whatever it is.
> So just take the string from field.selectionStart to field.selectionEnd

Yes - but if there is no selection, it could run the current statement
(the one 'below' the cursor).

Regards,
Thomas
Reply all
Reply to author
Forward
0 new messages