【发布时间】:2020-05-16 23:40:10
【问题描述】:
一个新列(BLOB 类型)已添加到远程数据库表中。我维护的应用程序通过一个视图读取该表,该视图是数据库链接上的简单选择语句。我需要更新视图,以便可以访问新列。
显然,您无法通过数据库链接读取 LOB 列:
ORA-22992: 无法使用从远程表中选择的 LOB 定位器
到目前为止,我只需要知道行是否有数据。此查询完美无缺:
select foo_id, foo_name, foo_date,
case
when foo_binary is not null then 1
else 0
end as has_foo_binary_data
from remote_table@remote_database;
但除非删除 case 表达式,否则我无法创建视图:
create view remote_foo as
select foo_id, foo_name, foo_date,
case
when foo_binary is not null then 1
else 0
end as has_foo_binary_data
from remote_table@remote_database;
RA-22992:无法使用从远程表中选择的 LOB 定位器
DBMS_LOB.GETLENGTH(foo_binary) 开始可爱的 catch-22:
ORA-02069:此操作的 global_names 参数必须设置为 TRUE
alter session set global_names = true`;
create view ...
ORA-02085: 数据库链接 remote_database 连接到 remote_sid
原因:数据库链接连接到具有不同名称的数据库。连接被拒绝。
操作:创建一个与其连接的数据库同名的数据库链接,或设置 global_names=false。
不知道我是不是碰壁了,或者我只是在犯愚蠢的错误。有什么方法可以获取关于视图中工作的 CLOB(不是 blob 数据)的任何信息?
【问题讨论】:
-
我猜你必须用 case 表达式在 remote db 上定义一个视图。