This answer on a question on SO says
... you can read a LONG from a remote database, but you can't read a CLOB
I did not find anything about this on the internet, is it true? Any documentation or citings for this will be helpful.
CLOBs require that you use the DBMS_LOB package to perform substr/instr type searches. In order to use do any kind of searching within the column, you must first get the locator for the CLOB column, the use the DBMS_LOB. SUBSTR or DBMS_LOB. INSTR function to search and/or pull part of the text from the string.
If you want to enable clob previews, go to View > TOAD Options > Data Grids > Data > check the "Preview CLOB and LONG data" box.
In Oracle, you can use LENGTH() or DBMS_LOB. GETLENGTH() function to get the length of a CLOB column in characters. There is LENGTHB() function to get the length in bytes, but it can be used for single-byte CLOBs only, so it will return the same result as LENGTH().
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.
@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 you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With