A query tab can hold one statement or a whole script. Two actions run them: - "Execute" runs one statement: the selection when there is one, and otherwise the statement the cursor is in. - "Execute All" runs every statement in the tab, one after another, in the order they appear. A selection is run exactly as selected, also when it holds several statements. "Select Current Statement" in the "Selection" menu shows which statement "Execute" would take. ## Licence Running every statement in a tab is licensed apart from running one statement. From release 27.0 onwards "Execute All" needs a licence which covers the function `itgen_querytool_execute_script`. "Execute" needs no function of its own. Without the function the button stays on the toolbar. The run is then refused before the first statement starts. The message names the function to acquire and appears in the messages pane as well. On a connection to an Invantive repository the function must be granted to the user too, as every function of such a repository is. On a connection without such a repository the licence is the only gate. See [[License Registration]]. A licence which covers the function covers it in [[Invantive Query Tool/Invantive Query Tool|Invantive Query Tool]] for Microsoft Windows as well, where "Execute All" needs the same function from release 27.0 onwards. ## Where a Statement Ends Statements are separated by a line which holds nothing, or which holds only `go`, or which holds only `/`. A semicolon does not separate statements; a semicolon at the end of the last line of a statement is removed before the statement is sent, unless that line ends in `end;`, which belongs to [[Procedural SQL]]. So the following text holds two statements: ```sql select code , description from ItemsIncremental select count(*) from ItemsIncremental ``` whereas the same text without the empty line in the middle is one statement and will not run. ## Client-side Statements Statements of [[Invantive Script]] which run on the device itself, such as `local export results`, are recognised as such and handled by the product instead of being sent to the platform. They are reported in the messages as a local statement with the time they took. `local exit` closes the window. ## While a Statement Runs The bar above the editor reports what the engine is doing and how long the statement has been running, refreshed twice a second. The row count and the duration are reported on the status bar and in the messages as soon as the statement is finished. "Execute All" reports every statement separately and the total afterwards, and stops at the first statement that fails. The button in that bar cancels. Cancelling does not interrupt the statement: the platform finishes the work, and the result is discarded as soon as it arrives. With "Execute All" the statements that have not started yet are dropped. A statement that fails writes the full error in the messages and opens a window with the message, the message code and the topics about that code on the product forums.