This content has been marked as final. Show 5 replies
I don't know if this is related, but we were also having a problem that was causing the ORA-22992 error, and the solution turned out to be surprisingly simple. A full day of searching the web didn't turn up this answer, but then one of our DBAs accidentally stumbled over something buried in some Oracle documentation that provided the answer.
We have a database table that contains a couple primary key fields (a varchar and an integer), plus a BLOB that holds Word documents. One of our programs needs to be able to connect to a remote Oracle instance and copy Word documents based on certain primary keys.
Our code first attempted to do that like this:
insert into [local Word doc table] ([key column1], [key column 2], [blob column])
values ('[key 1 literal]', [key 2 literal],
(select [blob column] from [Word doc table]@[remote instance]
where [keys = remote keys])
Attempting to execute that was giving us the "cannot use LOB locators selected from remote tables" error.
The documentation that our DBA turned up included a bunch of SQL examples of using remote BLOBs which he thought would be helpful. But what provided the solution was the sentence following the SQL examples: "In statements structured like the preceding examples, only standalone LOB columns are allowed in the select list".
I took that to mean that if you're going to access a BLOB on a remote database, then that BLOB column has to be the ONLY column you're referencing. So I broke our program's SQL up into this:
insert into [local Word doc table] ([key 1 col], [key 2 col], [blob col]) values
('[key 1]', [key 2], NULL)
update [local Word doc table] set [blob col] =
(select [blob col] from [Word doc table]@[remote instance]
where [keys = remote keys])
where [keys = local keys]
I was amazed to find that the above works like a charm. We've got a 100 meg Word document going from one Oracle instance to the other with no problem.
Since doing a Google search on "cannot use LOB locators selected from remote tables" turns this page up near the top of its list of links, I'm hoping that by posting this I can save another programmer somewhere the two or three days of banging your head against the screen that I just went though.
This is a good way of doing it.
It only works if you are inserting it into a table though, you still can't SELECT it directly.
I even tried using a function to return it but the Limit is ONLY 4000 for a VARCHAR return.
FUNCTION f_EmailBodyClobToVar2(p_nEHI_PK IN TAR_EMAIL_HISTORY.ehi_pk%TYPE)
WHERE ehi_pk = p_nEHI_PK;
Another way to go if you don't want to implement "INSERT" and "UPDATE" approach is to create a cursor and peroform the insert with in the cursor.
I have similar project where I have to insert to a table VIA DB_LINK and I keep getting ..
ORA-22992: cannot use LOB locators selected from remote tables.