Skip to Main Content
  • Questions
  • JSON Query using DBLINK or remote database

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Shobha Kashyap.

Asked: July 21, 2020 - 7:01 am UTC

Last updated: July 22, 2020 - 10:57 am UTC

Version: 12c

Viewed 1000+ times

You Asked

I have created a DB link using below query to link 12.1 version DB to 12.2 version DB. Since JSON is not supported in 12.1 version of the Oracle DB.

CREATE DATABASE LINK dblink_SBX
   CONNECT TO SOURCEDB IDENTIFIED BY SOURCEDB
   USING '(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = XYZ)(PORT = 1521))
  )
  (CONNECT_DATA =
  (SID= ABCD)
  )
  )';


I am trying to execute the JSON query in the DBLINK created Data base:

select JSON_OBJECT
('EMPNO' VALUE EMP_ID)
from EMP;


I also tried using DBLINK in the from clause like below:

select JSON_OBJECT
('EMPNO' VALUE EMP_ID)
from EMP@dblink_SBX;


I am getting below Error:

ORA-02063: preceding line from DBLINK_SBX 
00907. 00000 -  "missing right parenthesis" 
*Cause: *Action:


Please help.

PLEASE NOTE: am executing the JSON Query on 12.2 version DB where the DB LINK is created with SOURCE Data Base(12.1 version).

and Chris said...

The query you run must be valid syntax on the local database. JSON_object is a 12.2 feature, so:

select JSON_OBJECT
('EMPNO' VALUE EMP_ID)
from EMP@dblink_SBX;


Just won't work on 12.1, even though it's valid on the remote database.

Depending on what you're trying to do, you may be able to get around this by:

- Creating a function on the 12.2 database containing your query
- Calling the function over the DB link

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database