-1

有人可以告诉我是否可以在 isql plus 中显示行号吗?我看不到它的错误报告和实际行数之间的对应关系。

非常感谢。

4

1 回答 1

1

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

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

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

仅当您在行之间使用 Cj 而不是 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,如果是,它将添加

吃-sqlplus-junk 到 comint-preoutput-filter-functions。

(defun install-eat-sqlplus-junk () "comint-preoutput-filter-functions' if appropriate. Add this function to在你的 .emacs 中安装 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-program) (add-to-list 'comint-preoutput-filter-functions 'eat-sqlplus-junk)))) (add -hook 'sql-interactive-mode-hook 'install-eat-sqlplus-junk)

来源:这里

于 2013-05-01T14:53:28.507 回答