diff --git a/frontend-hyrise/sample-queries.sql b/frontend-hyrise/sample-queries.sql index 1ee10d2..d78fe3f 100644 --- a/frontend-hyrise/sample-queries.sql +++ b/frontend-hyrise/sample-queries.sql @@ -32,12 +32,14 @@ PREPARE select_test: SELECT * FROM students WHERE grade = ?; # EXECUTE 1 EXECUTE select_test(2.0); # PREPARE 2 -PREPARE insert_test: -INSERT INTO test VALUES (?, 0, 0); -INSERT INTO test VALUES (?, 0, 0); -INSERT INTO test VALUES (?, 0, 0); -INSERT INTO test VALUES (?, 0, 0); -INSERT INTO test VALUES (?, 0, 0); +PREPARE insert_test { + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); + INSERT INTO test VALUES (?, 0, 0); +}; +EXECUTE insert_test(1, 2, 3, 4 ,5); SELECT * FROM test; # EXECUTE 2 EXECUTE insert_test(1, 2, 3, 4, 5); diff --git a/frontend-hyrise/ui.js b/frontend-hyrise/ui.js index ae1ed46..f48a2ed 100644 --- a/frontend-hyrise/ui.js +++ b/frontend-hyrise/ui.js @@ -12,6 +12,13 @@ $(function() { var endpointUrl = $('#endpointInput').val(); var query = $('#queryInput').val(); + + // Check whether a part of the query has been selected + var selectedText = getSelectedText(); + if (query.indexOf(selectedText) >= 0) { + query = selectedText; + } + var hyrise = new HyriseSQLConnector(endpointUrl); hyrise.executeSQLQuery(query, function(result) { @@ -43,6 +50,16 @@ $(function() { }); +function getSelectedText() { + var text = ""; + if (window.getSelection) { + text = window.getSelection().toString(); + } else if (document.selection && document.selection.type != "Control") { + text = document.selection.createRange().text; + } + return (text === "") ? null : text; +} + function loadSampleQueries(url) { $.get(url, function(data) {