Is it possible to read a CLOB from a remote Oracle database?
The answer is correct in a certain context, for simple select statements over a DB link, you'll get this error:
ORA-22992: cannot use LOB locators selected from remote tables.
From the errors manual:
Cause: A remote LOB column cannot be referenced.
Action: Remove references to LOBs in remote tables.
I also had trouble finding definitive documentation on this...but we just ran into the same issue in our data warehouse. However, there are several work-arounds available, pulling the data over or creating a view for example.
Oracle 12.2 finally added support for distributed LOBs. We can now read data types like CLOB and XMLType over database links without any workarounds.
@Peter Ilfrich: Doesn't that throw an exception when trying to access any clobs over 4000 bytes?
This is a little more convaluted, but it means you can safely pull back small clobs (< 4000) over a dblink.
select dbms_lob.substr@<link>((select <columnName> from dual@<link>), 4000, 1)
from <table>@<link>
where dbms_lob.getlength@<link>((select <columnName> from dual@<link>)) <= 4000;
Reading a CLOB (or a BLOB) over a dblink is possible with this PL/SQL package:
https://github.com/HowdPrescott/Lob_Over_DBLink
If both DB schemes are in the same Oracle instance, you can use the following workaround:
select (select <columnName> from dual) <columnName> from <table>@<link>
This will return you the same as if you would access a local LOB column.