你如何在Oracle isql plus中显示行号?

时间:2013-05-01 14:41:07

标签: oracle line-numbers isql

有人能告诉我你是否可以在isql plus中显示行号?我无法看到其错误报告与实际行数之间的对应关系。

非常感谢。

1 个答案:

答案 0 :(得分:1)

SQL * Plus有一个有趣的功能:每当您输入一行输入时,SQL * Plus会在下一行的开头添加一个行号。此行号不是SQL命令的一部分;它只允许您在SQL命令中引用和编辑特定行。 SQL * Plus的作用类似于标准文本编辑器。 SQL * Plus在TheTruePath上。

使用SqlMode时,这可能会使SQL * Plus错误报告变得难以理解。以下是行号垃圾的示例:

...
  2    3    4       from v$parameter p, all_tables u
          *
ERROR at line 2:
ORA-00942: table or view does not exist

只有在使用C-j而不是行之间的RET输入多行SQL语句时才会发生这种情况(即使用sql-accumulate-and-indent而不是comint-send-input)。如果你一次输入一个SQL语句,你会没事的。

必须将以下elisp函数添加到comint-preoutput-filter-functions中,以便从输出中删除行号垃圾:

(defun eat-sqlplus-junk (str)
  "Eat the line numbers SQL*Plus returns.
Put this on `comint-preoutput-filter-functions' if you are
running SQL*Plus.    If the line numbers are not eaten, you get stuff like this:
...
  2    3    4       from v$parameter p, all_tables u
          *
ERROR at line 2:
ORA-00942: table or view does not exist    The mismatch is very annoying."
  (interactive "s")
  (while (string-match " [ 1-9][0-9]  " str)
    (setq str (replace-match "" nil nil str)))
  str)

通过评估以下表达式来测试它:

(string= "     from" (eat-sqlplus-junk "  2    3    4       from"))

通过将以下表达式添加到.emacs来安装它;它会检查你刚刚启动的iSQL模式是否确实正在运行SQL * Plus,如果是,它会添加

eat-sqlplus-junk to comint-preoutput-filter-functions。

(defun install-eat-sqlplus-junk()       “在你的.emacs中安装comint-preoutput-filter-functions' if appropriate. Add this function to sql-interactive-mode-hook”:     (add-hook'sql-mode-hook'install-eat-sqlplus-junk)“       (if(string =(car(process-command(get-buffer-process sql-buffer)))                    SQL-Oracle的程序)           (add-to-list'comint-preoutput-filter-functions                        'eat-sqlplus-junk)))(add-hook'sql-interactive-mode-hook'install-eat-sqlplus-junk)

来源:Here