环境:
Oracle 8.17
数据库一台,
Oracle 9i
数据库一台,两者间建有一个
DBLink
将相关的
shema
连接起来。在
Oracle 9i
这一端有一个
Table A,
如下:
Field Name |
Field Type |
…… |
….. |
||
confirm_time |
Timestamp |
|
creation_time |
Date |
|
…… |
情景:
有一个 Java 程序通过 JDBC 连接到 Oracle 8 那一端,现在这个应用程序需要通过 DBLink 访问 Oracle 9i 中的 Table A. 写下如下的查询语句:
select nvl(confirm_time, creation_time) from A@.....
该语句在 SQL Plus ( PL/SQL Developer )中执行能够完成并返回正确的结果,但将该语句放入 PreparedStatement 执行是,却得到错误:“ ORA-03115: unsupported network datatype or representation ”
原因分析:
Oracle 8 中还不存在 Timestamp 这样的数据类型,而无论是字段 confirm_time, 还是表达式 nvl(confirm_time, creation_time) 返回的都是 Timestamp 类型,故会得到 ORA-03115 的错误。(在 PL/SQL Developer 中为何不出错就不知道了,呵呵 …. 见笑见笑啦)
解决方法:
在 SQL 语句中将 Timestamp 转化为 Date 类型,如:
select nvl(to_date(to_char(confirm_time, “yyyy-mm-dd hh24:mi:ss”), “yyyy-mm-dd hh24:mi:ss”), creation_time) from A@........