@Test public void testGetErrorInfo() throws Exception { WbConnection con = OracleTestUtil.getOracleConnection(); assertNotNull(con); String sql = "create procedure nocando\n" + "as \n" + "begin \n" + " null; \n" + "ende;\n/\n"; TestUtil.executeScript(con, sql, DelimiterDefinition.DEFAULT_ORA_DELIMITER); try { con.setBusy(true); OracleErrorInformationReader reader = new OracleErrorInformationReader(con); ErrorDescriptor errorInfo = reader.getErrorInfo(null, "nocando", "procedure", true); con.setBusy(false); assertNotNull(errorInfo); assertTrue(errorInfo.getErrorMessage().startsWith("Errors for PROCEDURE NOCANDO")); assertTrue(errorInfo.getErrorMessage().contains("PLS-00103")); assertEquals(4, errorInfo.getErrorLine()); assertEquals(4, errorInfo.getErrorColumn()); errorInfo = reader.getErrorInfo(null, "nocando", "procedure", false); assertNotNull(errorInfo); String msg = errorInfo.getErrorMessage(); assertFalse(msg.contains("Errors for PROCEDURE NOCANDO")); assertTrue(msg.startsWith("L:5")); } finally { con.setBusy(false); } }
protected void retrieveCurrentTrigger() { if (this.dbConnection == null || this.reader == null) return; int row = this.triggerList.getSelectedRow(); if (!WbSwingUtilities.isConnectionIdle(this, this.dbConnection)) return; if (row < 0) return; final String triggerName = this.triggerList.getValueAsString(row, TriggerReader.COLUMN_IDX_TABLE_TRIGGERLIST_TRG_NAME); final String tableName = this.triggerList.getValueAsString( row, TriggerReader.COLUMN_IDX_TABLE_TRIGGERLIST_TRG_TABLE); final String comment = this.triggerList.getValueAsString( row, TriggerReader.COLUMN_IDX_TABLE_TRIGGERLIST_TRG_COMMENT); Container parent = this.getParent(); WbSwingUtilities.showWaitCursor(parent); try { if (dbConnection.getProfile().getUseSeparateConnectionPerTab()) { levelChanger.changeIsolationLevel(dbConnection); } dbConnection.setBusy(true); try { TableIdentifier tbl = null; if (tableName != null) { tbl = new TableIdentifier(tableName, dbConnection); if (tbl.getCatalog() == null) tbl.setCatalog(currentCatalog); if (tbl.getSchema() == null) tbl.setSchema(currentSchema); } DropType dropType = DbExplorerSettings.getDropTypeToGenerate(TriggerDefinition.TRIGGER_TYPE_NAME); String sql = reader.getTriggerSource(currentCatalog, currentSchema, triggerName, tbl, comment, true); Object obj = triggerList.getUserObject(row); boolean isReplace = SqlUtil.isReplaceDDL(sql, dbConnection, dropType); if (dropType != DropType.none && obj instanceof TriggerDefinition && sql != null && !isReplace) { TriggerDefinition trg = (TriggerDefinition) obj; String drop = trg.getDropStatement(dbConnection, dropType == DropType.cascaded); if (StringUtil.isNonBlank(drop)) { sql = drop + getDelimiterForDrop() + "\n\n" + sql; } } final String sourceSql = sql == null ? "" : sql; WbSwingUtilities.invoke( () -> { source.setText(sourceSql, triggerName, TRG_TYPE_NAME); }); } catch (Throwable ex) { LogMgr.logError( "TriggerListPanel.retrieveTriggerSource() thread", "Could not read trigger source", ex); source.setPlainText(ExceptionUtil.getDisplay(ex)); } } finally { WbSwingUtilities.showDefaultCursor(parent); levelChanger.restoreIsolationLevel(dbConnection); dbConnection.setBusy(false); } if (this.triggerList.getSelectedRowCount() == 1) { EventQueue.invokeLater( () -> { source.setCaretPosition(0, false); if (DbExplorerSettings.getSelectSourcePanelAfterRetrieve()) { source.requestFocusInWindow(); } }); } }