Get the App
SLTechnology News&Howtos  ›  Database  › 

How to solve the problem of CLOB reporting error ORA-22992 in Oracle DBLink

Shulou Source: shulou.com Published: 2022-05-31 15:06:33 10月27日 Update

This article introduces the relevant knowledge of "how to solve the CLOB error ORA-22992 in Oracle DBLink". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In DBLink, ordinary fields can be queried according to the conventional method, but the processing of CLOB fields is relatively troublesome. CLOB is a large field, and usually VARCHAR supports a maximum of 4000 characters. When querying according to the normal method, you will get the following results:

SELECT MODE_CODE,TRANSFORM_CHANGE_CONTENT from TABLE@ DBLINK, where "TRANSFORM_CHANGE_CONTENT" is a CLOB field, will report an error of "ORA-22992: cannot use LOB locators selected from remote tables".

There are two conventional processing methods:

1. The temporary table is used to select the LOB field:

Create a temporary table "create global temporary table TMP_TB (

MODE_CODE VARCHAR2 (16)

TRANSFORM_CHANGE_CONTENT CLOB

) on commit delete rows; "

After executing "INSERT INTO TMP_TB SELECT MODE_CODE,TRANSFORM_CHANGE_CONTENT from TABLE@ DBLINK;", the corresponding data is selected in the temporary table, and finally the structure can be seen by executing "SELECT * from TMP_TB;".

two。 Implement by converting CLOB to VARCHAR:

First you need to use the function "dbms_lob.substr (clob_column, for_how_many_bytes, from_which_byte);"

By creating the following view:

CREATE OR REPLACE VIEW DBLINK_V AS

SELECT MODE_CODE, dbms_lob.substr (TRANSFORM_CHANGE_CONTENT,4000,1) TRANSFORM_CHANGE_CONTENT

FROM TABLE

You can see the result by executing "SELECT MODE_CODE,TRANSFORM_CHANGE_CONTENT from DBLINK_V @ DBLINK;".

This is the end of the content of "how to solve the CLOB error ORA-22992 in Oracle DBLink". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Fields general methods content methods more knowledge results processing query practical ordinary maximum successful learning next functions dilemmas characters actual situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux Apple Docker Shulou Technology