Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Configuring Multiple Schemas within the same DB on ORDS

Vimal KannanAug 18 2017 — edited Aug 21 2017

Hi,

I am fairly new to ORDS and i have successfully installed the service and able to run it in the STANDALONE mode.

I am trying to join 2 tables under 2 different schemas as part of 1 GET request.

For example,

Schema 1

     Table 1

          Cols

               ID Description

Schema 2

     Table 2

          Cols    

               ID VALUE

My service is essentially this query - select a.description, b.value from table 1 a, table 2 b where a.ID = b.ID;

My questions are,

1. Do I need to enable REST services for both the schemas? If Yes, can they map to the same BASE PATH PATTERN?

2. Do I enable both tables as Objects through AutoRest?

Any suggestions is appreciated.

Thanks,

Vimal

Comments

thatJeffSmith-Oracle

You'll REST enable the SCHEMA you want to use for running the query behind your service.

So if you have a query that hits schemas A, B, C - you'll want to rest enable a schema whose USER will have the necessary privs to access those tables and views.

You could write a service to query SYS objects without enabling SYS - you'd simply enable a schema/USER that could query said SYS views. In fact, never ever ever REST enable SYS.

Vimal Kannan

Hi,

It doesn't seem to work.

I have a synonym for Table 2 on Schema 1.

I logged into Schema 2 and executed the following

GRANT SELECT ON TABLE 2 to SCHEMA 1.

I then tried to enable the REST object on Schema 1 for Table 1 and i am getting the following exception.

Failed to process SQL command

- ORA-01031: insufficient privileges

ORA-06512: at "ORDS_METADATA.ORDS_SECURITY", line 51

ORA-06512: at "ORDS_METADATA.ORDS", line 289

ORA-06512: at line 5

Any pointers?

Thanks,

Vimal

thatJeffSmith-Oracle

I then tried to enable the REST object on Schema 1 for Table 1 and i am getting the following exception.

How exactly did you try this?

Vimal Kannan

Through SQL Developer.

I am connected to both the schema's via SQL Developer.

So on Schema 1, I navigated to the Table and right clicked to Enable REST Services, selected the Enable Object and gave the Alias.

Here's the SQL for the same,

DECLARE

  PRAGMA AUTONOMOUS_TRANSACTION;

BEGIN

    ORDS.ENABLE_OBJECT(p_enabled => TRUE,

                       p_schema => '<schema 2>',

                       p_object => '<table 1>',

                       p_object_type => 'TABLE',

                       p_object_alias => '<alias name>',

                       p_auto_rest_auth => FALSE);

   

    commit;

END;

Thanks,

Vimal

thatJeffSmith-Oracle

So if you're on Schema 1, then why is p_schema set to 'schema 2'  ?

Vimal Kannan

That's what is confusing me as well.

I have registered both the schemas, even though i am connected to Schema 1.

Even though i picked Table 2 from the Table filter of Schema 1 (as i mentioned this a synonym), for some reason the SQL is always putting Schema 2 as the p_schema.

I also executed this query on schema 1, but it is not returning any rows.

SELECT parsing_schema,

       parsing_object,

       object_alias,

       type,

       status

FROM   user_ords_enabled_objects

ORDER BY 1, 2;

How can i check if Schema 1 is REST enabled?

Thanks,

Vimal

thatJeffSmith-Oracle

on your schema 1 connection, right click, enable rest - is the checkbox already checked? If so, it's enabled.

Or

select * from ORDS_METADATA.ORDS_SCHEMAS

Vimal Kannan

I see it Enabled. Please see screenshot below.

pastedImage_0.png

APPS and NAPPCUST are the Schema 1 and Schema 2 in this scenario.

Thanks,

Vimal

1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 18 2017
Added on Aug 18 2017
8 comments
818 views