12
返回列表 发新帖
楼主: Erichuchahui

“ora-00911,无效字符串”的问题,为什么是";"引起的

[复制链接]
论坛徽章:
1
双黄蛋
日期:2012-12-26 14:17:49
11#
发表于 2008-11-9 00:08 | 只看该作者
上传图片

未命.JPG (74.25 KB, 下载次数: 6)

未命.JPG

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
12#
发表于 2008-11-9 08:53 | 只看该作者
Many years ago I wrote about the anomaly of sqlplus edit window (see Item 7 of the following URL):

http://yong321.freeshell.org/computer/OracleIdiosyncrasies.html

I think it's related to the problem we're talking about here. But it's not exactly the same. Anyway, I rarely use edit command, other than these anomalies, it creates afiedt.buf in the directory where you launch sqlplus. If you don't clean up, the file becomes ugly litter everywhere on your filesystem.

Yong Huang

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
25
生肖徽章2007版:龙
日期:2008-05-06 11:07:48咸鸭蛋
日期:2011-10-19 10:09:12ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-01-04 11:49:542013年新春福章
日期:2013-02-25 14:51:24
13#
发表于 2008-11-9 23:19 | 只看该作者
ALTER SYSTEM SET CONTROL_FILES=
'H:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL02.CTL',
'H:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL03.CTL',
'H:\APP\ADMINISTRATOR\ORADATA\ORCL\CONTROL01.CTL',
'I:\Oracle back up\CONTROL04.CTL' SCOPE=SPFILE;
/

SQL> alter system set control_files=
  2  'D:\oracle\product\10.2.0\oradata\zero\CONTROL01.CTL,D:\oracle\product\10.2
.0\oradata\zero\CONTROL03.CTL,D:\oracle\product\10.2.0\oradata\zero\CONTROL03.CT
L,D:\oracle\product\10.2.0\oradata\test de\CONTROL04.CTL' scope=spfile;

楼主认真看看,这两个命令的区别。我这个绝对可以执行的。
你输入那么多的单引号做什么? 人家那个命令指向一个字符串的。

[ 本帖最后由 foxmile 于 2008-11-9 23:22 编辑 ]

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
14#
发表于 2008-11-10 01:33 | 只看该作者
wghxwl12's problem can be reproduced this way:

Type "select * from dual;" and hit Enter:

SQL> select * from dual;

D
-
X

Type edit, and in the popped-up Notepage window (assuming Windows), you have three lines (the 3rd line is just carriage return):
select * from dual
/

But here you append the semicolon ";" to the end of the SQL so it becomes:
select * from dual;
/

Exit Notepad and type "/":

SQL> ed
Wrote file afiedt.buf

  1* select * from dual;
SQL> /
select * from dual;
                  *
ERROR at line 1:
ORA-00911: invalid character


SQL>

The asterisk "*" points to ";". What should be done is either not use edit command or remember to not put ";" at the end of a SQL in the edit window. The edit window is not the same as a script file (say, myscript.sql) with these lines:
select * from dual;
/

When you run myscript.sql, sqlplus executes the SQL twice. But in an edit window, it throws the error ORA-911.

Yong Huang

使用道具 举报

回复
论坛徽章:
8
2009新春纪念徽章
日期:2009-01-04 14:52:28祖国60周年纪念徽章
日期:2009-10-09 08:28:002010新春纪念徽章
日期:2010-03-01 11:07:24ITPUB9周年纪念徽章
日期:2010-10-08 09:32:25ITPUB十周年纪念徽章
日期:2011-11-01 16:23:262013年新春福章
日期:2013-02-25 14:51:24沸羊羊
日期:2015-03-04 14:51:522015年新春福章
日期:2015-03-06 11:57:31
15#
发表于 2008-11-10 09:19 | 只看该作者
只要清楚,“;”号只是结束命令的标志,而不是命令必须的一部分就可以了,ORACLE命令里没有";"关键字,只是SQL*PLUS把他作为分隔命令与命令的分隔符号而已。如果可以定义,完全可以定义其他符号为命令分隔符,例如"!","#"等。

使用道具 举报

回复
论坛徽章:
1
双黄蛋
日期:2012-12-26 14:17:49
16#
发表于 2008-11-12 10:39 | 只看该作者
再贴一段:

SQL> select * from dual;

DU
--
X

SQL> edit
已写入 file afiedt.buf

  1* select * from dual;(--这里手工加入";")
SQL> /
select * from dual;
                  *
第 1 行出现错误:
ORA-00911: 无效字符


SQL> edit
已写入 file afiedt.buf

  1* select * from dual
SQL> /

DU
--
X


SQL> select * from dual;;(--注意这里,有两个";",然后看下面报的错误)
select * from dual;
                  *
第 1 行出现错误:
ORA-00911: 无效字符

SQL> select * from dual;;
select * from dual;
                  *
第 1 行出现错误:
ORA-00911: 无效字符


SQL> edit
(--此时在弹出的编辑面板里面可以看到语句是加了一个";"的)
已写入 file afiedt.buf

  1* select * from dual;
SQL> /
select * from dual;
                  *
第 1 行出现错误:
ORA-00911: 无效字符


SQL> ;
  1* select * from dual;

SQL> select * from dual;

DU
--
X



总结(需要大家共同论证)
在plussql中进行编辑, 保存在afiedt.buf中的sql语句如果手工加入了";";然后再执行相当于加入了两个":"
在plussql环境进行edit编辑时不要手工加入";"只需换行加入"/"就可以了


另外,同意“孤独剑客”所讲的【“;”号只是结束命令的标志,而不是命令必须的一部分就可以了,ORACLE命令里没有";"关键字,只是SQL*PLUS把他作为分隔命令与命令的分隔符号而已】

[ 本帖最后由 wghxwl12 于 2008-11-12 11:09 编辑 ]

ss.JPG (48.93 KB, 下载次数: 3)

ss.JPG

使用道具 举报

回复
论坛徽章:
10
授权会员
日期:2007-07-18 11:34:32ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44生肖徽章2007版:鸡
日期:2008-12-02 12:45:45生肖徽章2007版:龙
日期:2008-12-07 18:27:322009新春纪念徽章
日期:2009-01-04 14:52:28生肖徽章2007版:猪
日期:2009-02-18 12:56:472009日食纪念
日期:2009-07-22 09:30:00
17#
发表于 2008-11-12 17:32 | 只看该作者
在windows 下的解决方案:

D:\>set NLS_LANG=AMERICAN_AMERICA.UTF8

其中的NLS_LANG要跟你的数据一致.

然后再 sqlplus 就ok了.

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
18#
发表于 2008-11-13 03:30 | 只看该作者
原帖由 goodhawk 于 2008-11-12 03:32 发表
在windows 下的解决方案:

D:\>set NLS_LANG=AMERICAN_AMERICA.UTF8

其中的NLS_LANG要跟你的数据一致.

然后再 sqlplus 就ok了.


What problem are you referring to? The problem with sqlplus throwing ORA-911 error due to an extra comma in edit window?

Yong Huang

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表