Oracle 查看以通过数据库链接确定LOB列是否为空
向远程数据库表中添加了一个新列(属于Oracle 查看以通过数据库链接确定LOB列是否为空,oracle,oracle11g,Oracle,Oracle11g,向远程数据库表中添加了一个新列(属于BLOB类型)。我维护的应用程序通过数据库链接上的简单select语句视图读取该表。我需要更新视图,以便能够访问新列 显然,您无法通过数据库链接读取LOB列: ORA-22992:无法使用从远程表中选择的LOB定位器 到目前为止,我只需要知道行是否有数据。此查询工作正常: select foo_id, foo_name, foo_date, case when foo_binary is not null then 1 else 0 end a
BLOB
类型)。我维护的应用程序通过数据库链接上的简单select语句视图读取该表。我需要更新视图,以便能够访问新列
显然,您无法通过数据库链接读取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;
但是,除非删除大小写表达式,否则无法创建视图:
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\u LOB.GETLENGTH(foo\u二进制)
启动一个可爱的catch-22:
ORA-02069:对于此操作,必须将全局_names参数设置为TRUE
ORA-02085:数据库链接远程\u数据库连接到远程\u sid
原因:连接到具有不同名称的数据库的数据库链接。连接被拒绝
操作:创建与其连接的数据库同名的数据库链接,或将全局_name=false
不知道我是撞到墙了还是犯了愚蠢的错误。有什么方法可以获取视图中运行的CLOB(而不是blob数据)的相关信息吗?您已经发布了很多信息,因此我不打算重复所有内容 这是一个你可能需要考虑的选项;不是完美的,这取决于它是否合适。无论如何: 在远程数据库中更改表并添加新列:
alter remote_table add foo_binary_length number;
将其填充到数据库触发器中:
create or replace trigger trg_biu_remtab
before insert or update on remote_table
for each row
begin
:new.foo_binary_length := dbms_lob.getlength(:new.foo_binary);
end;
/
现在,在本地数据库中创建视图是一项简单的任务:
create view remote_foo as
select foo_id, foo_name, foo_date,
case
when foo_binary_length > 0 then 1 --> this
else 0
end as has_foo_binary_data
from remote_table@remote_database;
你已经发布了很多信息,所以我不打算全部重复 这是一个你可能需要考虑的选项;不是完美的,这取决于它是否合适。无论如何: 在远程数据库中更改表并添加新列:
alter remote_table add foo_binary_length number;
将其填充到数据库触发器中:
create or replace trigger trg_biu_remtab
before insert or update on remote_table
for each row
begin
:new.foo_binary_length := dbms_lob.getlength(:new.foo_binary);
end;
/
现在,在本地数据库中创建视图是一项简单的任务:
create view remote_foo as
select foo_id, foo_name, foo_date,
case
when foo_binary_length > 0 then 1 --> this
else 0
end as has_foo_binary_data
from remote_table@remote_database;
我想你必须用case表达式在远程数据库上定义一个视图。我想你必须用case表达式在远程数据库上定义一个视图。我明白了。。。如果我想得到已经发送的信息,我可以用case表达式创建一个虚拟列。不确定它到底有多可行(非常有进取心的环境,有很多官僚主义)。sighRight,一个虚拟专栏——出于某种原因(我无法解释),我认为它是在12c中引入的。更好的是,你不需要一个“昂贵的”触发器。我明白了。。。如果我想得到已经发送的信息,我可以用case表达式创建一个虚拟列。不确定它到底有多可行(非常有进取心的环境,有很多官僚主义)。sighRight,一个虚拟专栏——出于某种原因(我无法解释),我认为它是在12c中引入的。更好的是,你不需要一个“昂贵的”触发器。