oracle SQL*Plus - Spool CSV - SP2-0734:未知命令开始
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30219649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL*Plus - Spool CSV - SP2-0734: unknown command beginnin
提问by Ezequiel_075
When I launch the following task .cmd :
当我启动以下任务 .cmd 时:
sqlplus -s User/Password@database @Query.sql 'G:'
I get this error :
我收到此错误:
SP2-0734: unknown command beginnin
Even adding set sqlblanklines on
it failed.
即使添加设置sqlblanklines on
它也失败了。
With a simple query like select * from table1
it works.
使用简单的查询select * from table1
就可以了。
With a more complex query ( multiple join, group by) it does not work => Even if the file is well generated. Inside the file, I just find errors details.
使用更复杂的查询(多连接、分组依据)它不起作用 => 即使文件生成良好。在文件中,我只找到错误详细信息。
Please find below more details about the issue :
请在下面找到有关此问题的更多详细信息:
SP2-0734: unknown command beginning "FROM NOTI...." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0734: unknown command beginning "INNER JOIN..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "LEFT JOIN ..." - rest of line ignored.
SP2-0734: unknown command beginning "LEFT join ..." - rest of line ignored.
SP2-0734: unknown command beginning "LEFT join ..." - rest of line ignored.
SP2-0734: unknown command beginning "LEFT JOIN ..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning "LEFT join ..." - rest of line ignored.
SP2-0734: unknown command beginning "LEFT join ..." - rest of line ignored.
SP2-0734: unknown command beginning "WHERE NOTI..." - rest of line ignored.
SP2-0734: unknown command beginning "GROUP BY N..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SP2-0734: unknown command beginning ",table1..." - rest of line ignored.
SP2-0734: unknown command beginning ",table2..." - rest of line ignored.
回答by Alex Poole
By default SQL*Plus treats a blank line as terminating the previous command:
默认情况下,SQL*Plus 将空行视为终止前一个命令:
A blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet.
SQL 语句或脚本中的空行告诉 SQL*Plus 您已经完成了命令的输入,但还不想运行它。
The first blank line, before the FROM
, terminates the SELECT
- but it is not executed since the last line does not have a semicolon on the end and you don't have a /
on the next line. That partial SELECT
is held in the statement buffer but is never executed.
之前的第一个空行FROM
终止SELECT
- 但它不会执行,因为最后一行末尾没有分号并且/
下一行没有分号。该部分SELECT
保存在语句缓冲区中,但永远不会执行。
SQL*Plus then tries to interpret the rest of the file, but as each subsequent line doesn't start with something it recognises as SQL, and isn't a SQL*Plus command, you get SP2-0044 for all of them.
SQL*Plus 然后尝试解释文件的其余部分,但由于每个后续行都不是以它识别为 SQL 的内容开头,并且不是 SQL*Plus 命令,因此您将获得所有这些内容的 SP2-0044。
You can either remove the blank lines in the middle of the statement; or issue SET SQLBLANKLINES ON
at the start of your script:
您可以删除语句中间的空行;或SET SQLBLANKLINES ON
在脚本开头发出:
Controls whether SQL*Plus puts blank lines within a SQL command or script. ON interprets blank lines and new lines as part of a SQL command or script. OFF, the default value, does not allow blank lines or new lines in a SQL command or script or script.
控制 SQL*Plus 是否在 SQL 命令或脚本中放置空行。ON 将空行和新行解释为 SQL 命令或脚本的一部分。默认值 OFF 不允许在 SQL 命令或脚本或脚本中出现空行或新行。
回答by Anand Kumar
I got the same issue even i tried SET SQLBLANKLINES ON but no luck. I finally figured out the issue was with file encoding format. Actually I used to save my sql file using visual studio, which saves the file in utf-8 encoding format.
即使我尝试 SET SQLBLANKLINES ON 但没有运气,我也遇到了同样的问题。我终于发现问题出在文件编码格式上。其实我以前用visual studio来保存我的sql文件,它以utf-8编码格式保存文件。
solution- open sql file in notepad -> save as ANSI encoding format. it works.
解决方案-在记事本中打开sql文件->另存为ANSI编码格式。有用。
回答by Eats
SET SQLBLANKLINES ON did not work in my case where I use a cmd script to run and save sqlplus results as a txt file.
SET SQLBLANKLINES ON 在我使用 cmd 脚本运行并将 sqlplus 结果保存为 txt 文件的情况下不起作用。
Once I added a blank line between a "PROMPT" comment line and the first line of my select statement, the error went away. Before, my select statement line was immediately below the PROMPT line and would produce the SP2-0734.
一旦我在“PROMPT”注释行和我的 select 语句的第一行之间添加了一个空行,错误就消失了。之前,我的 select 语句行直接在 PROMPT 行下方,会生成 SP2-0734。