//======================================================================================== // Edit() //======================================================================================== internal override void Edit(River.Orqa.Query.QueryWindow window) { Statusbar.Message = "Reading text..."; OracleCommand cmd = new OracleCommand( "SELECT text" + " FROM dba_source" + " WHERE owner='" + schemaName + "' AND name='" + Text + "' AND type='PACKAGE BODY'" + " ORDER BY line", dbase.OraConnection ); try { OracleDataReader reader = cmd.ExecuteReader(); if (reader.FieldCount > 0) { StringBuilder text = new StringBuilder(); if (reader.Read()) { // Modify first line to insert cmd and qualify name // We purposefully do not trim the end to preserve the space string preamble = reader.GetString(0).Substring("PACKAGE BODY".Length).TrimStart(); text.Append( "CREATE OR REPLACE PACKAGE BODY " + schemaName + "." + preamble ); // append rest of content while (reader.Read()) { text.Append(reader.GetString(0)); } window.InsertText(text.ToString()); window.MoveHome(); window.IsSaved = true; window.SetTitle(schemaName + "." + this.Text); } } reader.Close(); reader.Dispose(); reader = null; } catch (Exception exc) { River.Orqa.Dialogs.ExceptionDialog.ShowException(exc); } Statusbar.Message = String.Empty; cmd.Dispose(); cmd = null; }
//======================================================================================== // Edit() //======================================================================================== internal override void Edit(River.Orqa.Query.QueryWindow window) { Statusbar.Message = "Reading view text..."; string sql = @"SELECT V1.owner, V1.view_name, V1.text, V2.comments FROM all_views V1 JOIN all_tab_comments V2 ON V2.owner = V1.owner AND V2.table_name = V1.view_name WHERE V1.view_name = '" + Text + @"' AND V1.owner = '" + schemaName + "'"; Logger.WriteLine(sql); using (var cmd = new OracleCommand(sql, dbase.OraConnection)) { // required to fetch the "text" column which is a LONG cmd.InitialLONGFetchSize = int.MaxValue; try { using (var reader = cmd.ExecuteReader()) { if (reader.FieldCount > 0) { if (reader.Read()) { var text = new StringBuilder(); text.Append("CREATE OR REPLACE VIEW "); text.Append(schemaName.ToUpper()); text.Append("."); text.Append(Text); text.Append("\n"); text.Append("AS "); text.Append("\n"); string body = reader.GetOracleString(2).ToString().TrimStart(); text.Append(body); window.InsertText(text.ToString()); window.IsSaved = true; window.SetTitle(schemaName + "." + this.Text); } } reader.Close(); } } catch (Exception exc) { River.Orqa.Dialogs.ExceptionDialog.ShowException(exc); } Statusbar.Message = String.Empty; } }
//======================================================================================== // Methods //======================================================================================== //======================================================================================== // Compile() // If an inheritor allows compilation (CanCompile == true), then the inheritor // should override this method to compile itself. //======================================================================================== internal override void Compile(River.Orqa.Query.QueryWindow window) { Statusbar.Message = "Compiling..."; string sql = "SELECT text" + " FROM dba_source" + " WHERE owner='" + schemaName + "' AND name='" + Text + "' AND type='TRIGGER'" + " ORDER BY line"; using (var cmd = new OracleCommand(sql, dbase.OraConnection)) { try { using (OracleDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { // Modify first line to insert cmd and qualify name // We purposefully do not trim the end to preserve the space string preamble = reader.GetString(0).Substring("TRIGGER".Length).TrimStart(); var text = new StringBuilder(); text.Append("CREATE OR REPLACE TRIGGER " + schemaName + "." + preamble ); // append rest of content while (reader.Read()) { text.Append(reader.GetString(0)); } window.InsertText(text.ToString()); window.IsSaved = true; window.SetTitle(schemaName + "." + this.Text); window.MoveHome(); } reader.Close(); } Statusbar.Message = String.Empty; } catch (Exception exc) { River.Orqa.Dialogs.ExceptionDialog.ShowException(exc); } } if (window != null) { window.Execute(ParseMode.Sequential); } }
private void DoDescribeCompleted(object sender, RunWorkerCompletedEventArgs e) { object[] args = (object[])e.Result; string ddl = (string)args[0]; string owner = (string)args[1]; string name = (string)args[2]; River.Orqa.Query.QueryWindow window = (River.Orqa.Query.QueryWindow)args[3]; window.InsertText(ddl); window.IsSaved = true; window.SetTitle(owner + "." + name); window.SetStatusMessage("Ready"); }
//======================================================================================== // Compile() // If an inheritor allows compilation (CanCompile == true), then the inheritor // should override this method to compile itself. //======================================================================================== internal override void Compile(River.Orqa.Query.QueryWindow window) { Statusbar.Message = "Compiling..."; OracleCommand cmd = new OracleCommand( "SELECT text" + " FROM dba_source" + " WHERE owner='" + schemaName + "' AND name='" + Text + "' AND type='PACKAGE BODY'" + " ORDER BY line", dbase.OraConnection ); try { OracleDataReader reader = cmd.ExecuteReader(); if (reader.FieldCount > 0) { StringBuilder text = new StringBuilder(); if (reader.Read()) { // Modify first line to insert cmd and qualify name // We purposefully do not trim the end to preserve the space string preamble = reader.GetString(0).Substring("PACKAGE BODY".Length).TrimStart(); if (preamble.IndexOf("wrapped") > 0) { window.Close(); MessageBox.Show( "Unable to compile package body; contents are wrapped.", "Wrapped Content", MessageBoxButtons.OK, MessageBoxIcon.Information ); } else { text.Append("CREATE OR REPLACE PACKAGE BODY " + schemaName + "." + preamble ); // append rest of content while (reader.Read()) { text.Append(reader.GetString(0)); } window.InsertText(text.ToString()); window.IsSaved = true; window.SetTitle(schemaName + "." + this.Text); window.MoveHome(); } } } reader.Close(); reader.Dispose(); reader = null; Statusbar.Message = String.Empty; } catch (Exception exc) { River.Orqa.Dialogs.ExceptionDialog.ShowException(exc); } cmd.Dispose(); cmd = null; if (window != null) { window.Execute(ParseMode.Sequential); } }