******这条SQL为什么不能执行,解决立即给分*****

Ranma_True 2004-07-11 03:42:09
表结构如下:
create table T1
(
SID VARCHAR2(10),
SNAME VARCHAR2(20),
VAL1 VARCHAR2(20),
VAL2 NUMBER,
VAL3 DATE
)
create table T2
(
SID VARCHAR2(10),
VAL1 DATE
)
表T1内容如下:
1 Insert into t1 values ('a','aa','aa1',1,to_date('2003-03-03','yyyy-mm-dd'))
2 Insert into t1 values ('b','bb','bb1',1,to_date('2003-04-03','yyyy-mm-dd'))
3 Insert into t1 values ('c','cc','cc1',1,to_date('2003-05-03','yyyy-mm-dd'))
4 Insert into t1 values ('d','dd','dd1',1,to_date('2003-06-03','yyyy-mm-dd'))

表T2内容如下:
1 Insert into t2 values ('a',to_date('2003-03-01','yyyy-mm-dd'))
2 Insert into t2 values ('b',to_date('2003-04-01','yyyy-mm-dd'))
3 Insert into t2 values ('c',to_date('2003-05-01','yyyy-mm-dd'))

Q1.Oracle9不支持以下语句?
select sid as tID,sname as tNAME from t1
where tid='b'
如果我要表示选择sid='b'的记录,难道必须用where sid='b'而不能用where tid='b'吗?
如果语句改为
select sid || sname as tCbo from t1
想从中找出sid || sname='bbb'的记录难道也只能用where sid || sname='bbb',而不能用where tCbo='bbb'吗?
如果是更复杂的复合字段呢?

Q2.经典错误ora-03113
执行以下语句
select * from
(
select sid || sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And to_char(val1,'yyyymm')='200303')
then '是' else '否' end) as f
from t1
)
where f='d'
先报ora-03113 通信通道的文件结束,再报ora-03114 未连接到oracle,将where f='d'改为where tcbo='d',错误消失。
...全文
271 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
bzszp 2004-07-14
  • 打赏
  • 举报
回复
是case when语句的问题,应该是一个bug,:)
我把上面的语句改写成decode,实现相同的功能,没有任何问题
SQL> select * from (
2 select tcbo,decode(nvl(sign,0),1,'是','否') f from (
3 select sid||sname as tCbo,
4 (Select 1 From t2
5 Where sid=t1.sid And to_char(val1,'yyyymm')='200303'
6 ) as sign from t1)
7 )
8 where f='是';

TCBO F
------------------------------ --
aaa 是

SQL>
Ranma_True 2004-07-14
  • 打赏
  • 举报
回复
up
jackjingsg 2004-07-13
  • 打赏
  • 举报
回复
我在winxp/orale 9.2.0.1测试没有问题,你可以考虑一下oracle的网络配置以及字符集设置
Ranma_True 2004-07-13
  • 打赏
  • 举报
回复
to jackjingsg(飞翔的精灵):
老兄,你把你的代码试验成功后再给我好吗?
你给我的代码出了一样的问题。
我的环境是win2000prosp4+oracle9.2.0.1.0,客户端和服务器都在一台机器上,
服务器进程也没死。
jackjingsg 2004-07-13
  • 打赏
  • 举报
回复
第二个问题可以写成:
select * from
( select sid || sname as tCbo,
(case when exists
(Select sid From t2 Where sid=t1.sid And to_char(val1,'yyyymm')
='2003 03' )
then '是'
else '否' end) as f
from t1
) t2
where t2.f='是'
jackjingsg 2004-07-13
  • 打赏
  • 举报
回复
----错误码解释如下:
Cause

An unexpected end-of-file was processed on the communication channel. The problem could not be handled by the Net8, two task, software. This message could occur if the shadow two-task process associated with a Net8 connect has terminated abnormally, or if there is a physical failure of the interprocess communication vehicle, that is, the network or server machine went down.
Action
If this message occurs during a connection attempt, check the setup files for the appropriate Net8 driver and confirm Net8 software is correctly installed on the server. If the message occurs after a connection is well established, and the error is not due to a physical failure, check if a trace file was generated on the server at failure time. Existence of a trace file may suggest an Oracle internal error that requires the assistance of customer support.

--你一直都认识不到你所应用f的结果集是什么
Ranma_True 2004-07-13
  • 打赏
  • 举报
回复
to rolandzhang() :
第二个问题按你的写法仍未解决。


to jackjingsg(飞翔的精灵) :
汉字和字母不都是字符串吗?有什么不能比较的,即使都改成字母或汉字,也是出一样的问题。
jackjingsg 2004-07-13
  • 打赏
  • 举报
回复
你要明白你的f结果集是什么,你把汉字与字母比较,oracle怎么可以认识?
Ranma_True 2004-07-13
  • 打赏
  • 举报
回复
to jackjingsg(飞翔的精灵):
我的别的语句执行都没问题,就这个语句出问题了。
hlooo 2004-07-12
  • 打赏
  • 举报
回复
ORA-03113:end-of-file on communication channel

产生原因:通讯不正常结束,从而导致通讯通道终止

解决方法:1>.检查是否有服进程不正常死机,可从alert.log得知

2>.检查sql*Net Driver是否连接到ORACLE可执行程序

3>.检查服务器网络是否正常,如网络不通或不稳定等

4>.检查同一个网上是否有两个同样名字的节点

5>.检查同一个网上是否有重复的IP地址

Ranma_True 2004-07-12
  • 打赏
  • 举报
回复
关键是第二个问题
Ranma_True 2004-07-12
  • 打赏
  • 举报
回复
还有要注意:
我的数据库在本地机上。
数据库连接绝对没问题。
rolandzhang 2004-07-12
  • 打赏
  • 举报
回复
针对:select sid as tID,sname as tNAME from t1 where tid='b' 可以写成
select * from (select sid as tID,snmae as tNAME from t1) where tid='b'
第二个问题可以写成:
select * from
( select sid || sname as tCbo,
(case when exists
(Select sid From t2 Where sid=t1.sid And to_char(val1,'yyyymm')
='2003 03' )
then '是'
else '否' end) as f
from t1
) t2
where t2.f='d'
Ranma_True 2004-07-12
  • 打赏
  • 举报
回复
to hlooo(天穹飞雨) :
可我的服务器在本地机上,而且通过plsql developer执行其他sql语句没问题,再执行这条就出问题了,然后再执行其他的sql也没问题。
sunnyrain 2004-07-11
  • 打赏
  • 举报
回复
关于Q2.我还遇到更离奇的,同一句sql,在相同内容的不同主机不同主机上,一台没问题,一台报和楼主一样的错误
sunnyrain 2004-07-11
  • 打赏
  • 举报
回复
Q1.--在order by 里面可用,在where里面不能用的
Q2.--这个问题我也遇到过,暂时还没解决,估计f包含null
Ranma_True 2004-07-11
  • 打赏
  • 举报
回复
1.
select sid as tID,sname as tNAME from t1
where tid='b'
Oracle9:"tid",无效的标志符。
Asa9:正常执行。
Sql Server2000:列名 'tid' 无效。


2.
select sid || sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And to_char(val1,'yyyymm')='200303')
then '是' else '否' end) as f
from t1
Oracle9:正常执行。

select sid + sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And year(val1)=2003 and month(val1)=03)
then '是' else '否' end) as f
from t1
Asa9:正常执行。
Sql Server2000:正常执行。


3.
select * from
(
select sid || sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And to_char(val1,'yyyymm')='200303')
then '是' else '否' end) as f
from t1
)
Oracle9:正常执行。

select * from
(
select sid + sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And year(val1)=2003 and month(val1)=03)
then '是' else '否' end) as f
from t1
) tt
Asa9:正常执行。
Sql Server2000:正常执行。


4.
select * from
(
select sid || sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And to_char(val1,'yyyymm')='200303')
then '是' else '否' end) as f
from t1
)
where f='d'
Oracle9:先报ora-03113 通信通道的文件结束,再报ora-03114 未连接到oracle,将where f='d'改为where tcbo='d',错误消失。


select * from
(
select sid + sname as tCbo,
(case when exists(Select sid From t2
Where sid=t1.sid And year(val1)=2003 and month(val1)=03)
then '是' else '否' end) as f
from t1
) tt
where f='d'
Asa9:正常执行。
Sql Server2000:正常执行。
Ranma_True 2004-07-11
  • 打赏
  • 举报
回复
to welyngj(不做老实人):
不好意思,select sid as tID,sname as tNAME from t1
where tid='b'是我搞错了,这个语句在sql server2000上执行的确出错了,我没经过试验就说没问题,是我弄错了,不过在asa9上确实没错,ase我没环境,但和asa属同一家,应该也没错。
我把我的试验结果贴上来。
welyngj 2004-07-11
  • 打赏
  • 举报
回复
在sqlserver2000上运行:

select phone,zip z from pubs..authors where z=94025
服务器: 消息 207,级别 16,状态 3,行 1
列名 'z' 无效。
Ranma_True 2004-07-11
  • 打赏
  • 举报
回复
建表语句我都给出来了,你可以分别在各种数据库上试验我说的话。
加载更多回复(4)

17,090

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧