5 Replies Latest reply: May 11, 2009 6:51 PM by 659137 RSS

    DBLink problem ORA-22992

      Hi all !!

      I'm using an active dblink between db1 and db2 named orcl. Database db2 in schema usr has a couple of tables A and B looking like that:

      Table A
      column id number, primary key
      column id_ref, number, not null,
      column eventdate date not null
      column longfield CLOB

      Table B
      column id_ref, number, primary key
      column description varchar2(256) not null

      In database db1 I ran the following query:


      and It works fine... But, If I try to run the following query:

      ON (A.ID_REF = B.ID_REF);

      I get the following message:

      ERROR in line 1:
      ORA-22992: cannot use LOB locators selected from remote tables

      db1 is an Oracle Database 10g Enterprise Edition Release - 64bit Production running over solaris

      db2 is an Oracle Database 10g Release - 64bit Production With the Real Application Clusters option, running over solaris

      How can I solve this problem ? Any help will be appreciated

      Thanks in Advance
        • 1. Re: DBLink problem ORA-22992
          Can you create a view on the remote database that joins A & B? If so, try referring to that remote view instead.

          Distributed Database Consulting, Inc.
          • 2. Re: DBLink problem ORA-22992
            Thanks for your answer...

            But, look at this curious thing: I re-write the query as follows:

            FROM A@ORCL A, B@ORCL B
            WHERE A.ID_REF = B.ID_REF;

            and it works fine... It seems like Oracle don't like the ANSI SQL92...
            • 3. Re: DBLink problem ORA-22992
              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.
              • 4. Re: DBLink problem ORA-22992
                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)
                RETURN VARCHAR2
                v_email_body_v2 VARCHAR2(32767);


                SELECT SUBSTR(email_body,1,32767)
                INTO v_email_body_v2
                FROM tar_email_history
                WHERE ehi_pk = p_nEHI_PK;

                RETURN v_email_body_v2;

                END f_EmailBodyClobToVar2;
                • 5. Re: DBLink problem ORA-22992
                  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.