//======================================================================================== // ShowOpenTransactions() //======================================================================================== /// <summary> /// Opens a new query window and executes the SELECT FROM v$transaction statement. /// </summary> public void ShowOpenTransactions() { string formattedSQL = "SELECT vp.spid as pid, S.blocking_session blocker, S.sid, S.serial#,\n" + " s.osuser, S.username, S.machine, S.program,\n" + " Q.sql_fulltext as cur_sql, PQ.sql_fulltext as prev_sql,\n" + " vt.used_urec, vt.start_date\n" + " FROM v$session S\n" + " LEFT JOIN v$sqlarea Q on S.sql_id = Q.sql_id\n" + " LEFT JOIN v$sqlarea PQ on S.prev_sql_id = PQ.sql_id\n" + " LEFT JOIN v$process vp on s.paddr = vp.addr\n" + " LEFT JOIN v$transaction vt on s.saddr = vt.ses_addr\n" + " ORDER BY S.username, S.machine\n"; InsertText(formattedSQL); IsSaved = true; SetTitle(); Logger.WriteLine("QueryWindow.ShowOpenTransactions"); commander.ExecuteControls.IsEnabled = true; SetStatusMessage(RxExecutingStatus); resultsView.Clear(); if (splitContainer.Panel2Collapsed) { DoToggleResults(null, null); } splitContainer.SplitterDistance = (int)(splitContainer.Height * 0.25); // catch up on Windows messages just to look better Application.DoEvents(); queries.Clear(); driver.Reset(); var query = new Database.Query(formattedSQL.Replace("\n", String.Empty)); var parser = new StatementParser(); parser.ParseStatement(dbase, query, browser); queries.Add(query); // execute query collection resultsView.Lock(); driver.Execute(queries, basePath, 1); }
private void Execute(ParseMode parseMode, string text, int repeat) { Logger.WriteLine("QueryWindow.Execute"); commander.ExecuteControls.IsEnabled = true; SetStatusMessage(RxExecutingStatus); resultsView.Clear(); if (splitContainer.Panel2Collapsed) { DoToggleResults(null, null); } // catch up on Windows messages just to look better Application.DoEvents(); queries.Clear(); driver.Reset(); var parser = new StatementParser(); parser.ParseNotification += new NotificationEventHandler(DoParseNotification); StatementCollection statements = GetStatementCollection(parseMode, text); // build collection of parsed queries Database.Query query; System.Collections.Specialized.StringEnumerator e = statements.GetEnumerator(); while (e.MoveNext()) { query = new Database.Query(e.Current); parser.ParseStatement(dbase, query, browser); if (parseMode == ParseMode.SqlPlus) { query.QueryType = QueryType.SqlPlus; } queries.Add(query); } // execute query collection resultsView.Lock(); driver.Execute(queries, basePath, repeat); }
//======================================================================================== // ShowOpenCursors() //======================================================================================== /// <summary> /// Opens a new query window and executes the SELECT FROM v$open_cursors statement. /// </summary> public void ShowOpenCursors() { string formattedSQL = "SELECT count(*), sql_text\n" + " FROM v$open_cursor\n" + " GROUP BY sql_text\n" + " ORDER BY 1 DESC\n"; InsertText(formattedSQL); IsSaved = true; SetTitle(); //Execute(ParseMode.Sequential, editorView.SelectedText, 1); Logger.WriteLine("QueryWindow.ShowOpenCursors"); commander.ExecuteControls.IsEnabled = true; SetStatusMessage(RxExecutingStatus); resultsView.Clear(); if (splitContainer.Panel2Collapsed) { DoToggleResults(null, null); } splitContainer.SplitterDistance = (int)(splitContainer.Height * 0.2); // catch up on Windows messages just to look better Application.DoEvents(); queries.Clear(); driver.Reset(); var query = new Database.Query(formattedSQL.Replace("\n", String.Empty)); var parser = new StatementParser(); parser.ParseStatement(dbase, query, browser); queries.Add(query); // execute query collection resultsView.Lock(); driver.Execute(queries, basePath, 1); }
public void ParseBlockStatementTest() { //Create parser StatementParser statementParser = new StatementParser(Init("{\n\techo \"test\";\n}")); Statement parsedStatement = statementParser.ParseStatement(); //Test statement Assert.AreEqual(typeof(BlockStatement), parsedStatement.GetType()); //Test BlockStatement BlockStatement statement = (BlockStatement)parsedStatement; Assert.AreEqual(1, statement.GetStatements().Count); //Test substatement List <ISyntaxNode> .Enumerator statementEnum = statement.GetStatements().GetEnumerator(); statementEnum.MoveNext(); Assert.AreEqual(typeof(EchoExpressionStatement), statementEnum.Current.GetType()); Assert.AreEqual("echo \"test\";", statementEnum.Current.ToString()); }