Menu

SQL Editor, execute Statement

General
Marco
2008-12-29
2013-05-01
  • Marco

    Marco - 2008-12-29

    Hi all,
    I have just a simple question.
    I have a sql file with multiple statements.
    Is there a way to execute only the selected statment in the sql editor?
    Greetings
    Marco

     
    • johnnyh

      johnnyh - 2009-01-04

      Dear Marco,

      That depends on the version of Quantum you use and on the line endings of your statements. I verified this with 3.3.0 and the internal Derby database,

      If all is well, you simply select the statements you want to run, and then right click and execute (or hit shift-control-q.

      Whether this is successful, depends on whether the statements can be parsed. Currently quantum splits the statements on a ; . Even if you use SQL Server we recommend to end the statements like this. This makes your SQL more portable to other databases.

      Hope this helps,

      Kind regards,

      Jan

       
      • Marco

        Marco - 2009-01-05

        Hi Jan,
        I have Quantum version 3.3.0 installed.
        My two statements are ending with ; and I use MySql.

        If I select the first statement in "Quantum SQL2 Editor" and try to execute this statement, all statements will be executed. As result I get the last sql statement.

        If I do the same in "Quantum SQL Queries View" everything works fine.

        It seems that this feature is not implemented for the Editor.

        Can you confirm this?

        Best wishes
        Marco

         
    • Marco

      Marco - 2009-01-11

      Yipii... finally I found out what the problem was.

      It was a little bug in Quantum version 3.3.0

      I just did following modification in com.quantum.editors.SQL2Editor.java

      change following method:

          public String getQuery() {
              return getSourceViewer().getTextWidget().getText();
          }

      to

          public String getQuery() {
             
              String query;

              if (getSourceViewer().getTextWidget().getSelectionText().length() > 0)
                  query = getSourceViewer().getTextWidget().getSelectionText();
              else
                  query = getSourceViewer().getTextWidget().getText();
             
              return query;
          }

      With this modification the behavoir(and also the source) is equal with Quantum SQL Queries View.

      Cheers!
      Marco

       
    • Julen Parra

      Julen Parra - 2009-01-12

      Great! I'll check it into the main source tree. Sorry for not answering before, I keep getting no mails from sourceforge.net.

      Thanks for your contribution.

      Julen.

       

Log in to post a comment.

MongoDB Logo MongoDB