powershell/sqlplus 错误 SP2-0042:未知命令■@"- 其余行被忽略 [英] powershell/sqlplus error SP2-0042: unknown command " ■@" - rest of line ignored
问题描述
我在 powershell 中运行此命令:
sqlplus system/passwd@mydb @my_sql
我已经尝试过使用和不使用反引号以及我通过 Google 找到的各种其他版本.当命令传递给 sqlplus 并且找不到修复程序时,我不断收到错误消息.希望这里有人可以帮忙吗?
我得到的错误是:
连接到:Oracle 数据库 11g 企业版 11.2.0.1.0 版 - 64 位生产使用分区、OLAP、数据挖掘和实际应用程序测试选项SP2-0042:未知命令■@" - 其余行被忽略.
所以我成功连接到数据库,但是在'@'前面有一个额外的字符被传递给sqlplus.记事本++中的"■@"看起来像|@"
如果您在 powershell 中使用重定向(> 或 >>)创建了 SQL 命令文件 - 例如:
myProgram > mySQL.out
然后像这样运行它:
&sqlplus mypw/myuser@mydb.xyz.com "@mySQL.out"
Powershell 可能将输出文件保存为 UTF-16 格式,Sqlplus 不喜欢这种格式.(您可以通过手动创建完全相同的文件然后进行比较来确认 - 字节数将关闭,并且在 KDiff 中,您将收到文本相等的消息,但文件不是二进制相等的).>
要修复 - 您需要做两件事::
- 在 SQL 命令的顶部添加一些空行 - Powershell 仍会在那里写入 BOM(字节顺序标记),看起来很难避免这种情况 - 但 sqlplus 只会通过它,尽管给出错误 - 但会继续执行其余代码.
- 然后在创建文件之前在 powershell 中运行此命令:$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
请参阅将 PowerShell 的默认输出编码更改为 UTF-8
我收到此错误:
SP2-0042:未知命令S" - 其余行被忽略.
这解决了这个问题 - 或者至少我能够运行它.您也可以使用 Notepad++ 将其从一个窗口剪切并粘贴到另一个窗口中,这将解决 BOM 和编码问题.
I am running this command in powershell:
sqlplus system/passwd@mydb @my_sql
I have tried it with and without backticks and various other versions I found via Google. I keep getting an error when the command is passed off to sqlplus and have been unsucessful in finding the fix. Hopefully someone here can help out?
The error I get is:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SP2-0042: unknown command " ■@" - rest of line ignored.
So I am sucessfully connecting to the database but there is an extra character being passed to sqlplus in front of the '@'. " ■@" in notepad++ looks like " ¦@"
If you created your SQL command file using a redirect (> or >>) in powershell - like:
myProgram > mySQL.out
and then run it like:
&sqlplus mypw/myuser@mydb.xyz.com "@mySQL.out"
Powershell may have saved the output file in UTF-16 format, which Sqlplus does not like. (You can confirm by creating the exact same file by hand and then comparing it - byte count will be off and in KDiff you'll get message to the effect that the text is equal, but the files are not binary equal).
To fix - you need to do two things: :
- Add some blank lines to the top of your SQL commands - Powershell will still write a BOM (Byte Order Mark) there and it looks like it's pretty hard to get it to avoid that - but sqlplus will just go by it, albeit giving an error - but will move on to the rest of your code OK.
- And then run this command in powershell before creating your file: $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
See Changing PowerShell's default output encoding to UTF-8
I received this error:
SP2-0042: unknown command " ■S" - rest of line ignored.
and this fixed that - or at least I was able to run it. You can also just cut and past it from one window into another using Notepad++ and that will solve the BOM and encoding issue.
这篇关于powershell/sqlplus 错误 SP2-0042:未知命令■@"- 其余行被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!