//======================================================================================== // 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); } }
//======================================================================================== // 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); } }