Skip to Main Content

SQL & PL/SQL

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!

Using Returning clause in an Insert with Select from Json_table?

Ryansun-OracleMay 18 2022

12 g
Hi Gurus,

I am passing a Clob parameter to a procedure that has JSON data in the following format

{
"items": [
        {
            "Col_b": "some data here",
            "Col_c": "some data here"
        }
    ]
} 

Table structure
Create table Test_Insert
(
Col_a Number GENERATED BY DEFAULT ON NULL AS IDENTITY,
Col_b varchar2(200),
Col_c varchar2(200)
);

I am extracting the data from this Json input with the following query
Insert into test_insert (Col_b,Col_c) select * from json_table(p_data , '$.items[*]'
          COLUMNS (
            COL_B VARCHAR2 PATH '$.Col_b',
            COL_C VARCHAR2  PATH '$.Col_c'
  )) RETURNING COL_A into somevariable

Is there a way to get the COL_A with the latest identity value populated in anyway? My this JSON input is coming from a VB application and is always going to be a single record only. The insert with select is only used to parse the JSON input.

I want to get the identity column of the latest insert some way.
Thanks
Sunil

This post has been answered by Paulzip on May 18 2022
Jump to Answer
Comments
Post Details
Added on May 18 2022
2 comments
466 views