<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How to save single Json data to multiple Oracle table in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-save-single-Json-data-to-multiple-Oracle-table/m-p/391624#M247696</link>
    <description>&lt;P&gt;Need to save Json data to multiple child tables. How should i do?&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2024 05:15:22 GMT</pubDate>
    <dc:creator>Adyant001</dc:creator>
    <dc:date>2024-08-12T05:15:22Z</dc:date>
    <item>
      <title>How to save single Json data to multiple Oracle table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-save-single-Json-data-to-multiple-Oracle-table/m-p/391624#M247696</link>
      <description>&lt;P&gt;Need to save Json data to multiple child tables. How should i do?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 05:15:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-save-single-Json-data-to-multiple-Oracle-table/m-p/391624#M247696</guid>
      <dc:creator>Adyant001</dc:creator>
      <dc:date>2024-08-12T05:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to save single Json data to multiple Oracle table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-save-single-Json-data-to-multiple-Oracle-table/m-p/391673#M247721</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/113398"&gt;@Adyant001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Need to save Json data to multiple child tables. How should i do?&amp;nbsp;&amp;nbsp;&lt;A href="https://www-choiceadvantage.com" target="_blank" rel="noopener"&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FFFFFF"&gt;choice advantage login&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To save JSON data to multiple Oracle tables, use the JSON_TABLE function to parse the JSON and then insert the parsed data into the respective tables. Here’s a concise example:&lt;/P&gt;&lt;P&gt;Parse JSON Data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT *
FROM JSON_TABLE(
  '{"employee": {"id": 1, "name": "John Doe", "department": "Sales", "address": {"street": "123 Main St", "city": "Anytown", "state": "CA"}}}',
  '$.employee'
  COLUMNS (
    id NUMBER PATH '$.id',
    name VARCHAR2(50) PATH '$.name',
    department VARCHAR2(50) PATH '$.department',
    street VARCHAR2(50) PATH '$.address.street',
    city VARCHAR2(50) PATH '$.address.city',
    state VARCHAR2(2) PATH '$.address.state'
  )
) jt;&lt;/LI-CODE&gt;&lt;P&gt;Insert Data into Tables&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;-- Insert into employee table
INSERT INTO employee (id, name, department)
SELECT id, name, department
FROM JSON_TABLE(
  '{"employee": {"id": 1, "name": "John Doe", "department": "Sales", "address": {"street": "123 Main St", "city": "Anytown", "state": "CA"}}}',
  '$.employee'
  COLUMNS (
    id NUMBER PATH '$.id',
    name VARCHAR2(50) PATH '$.name',
    department VARCHAR2(50) PATH '$.department'
  )
);

-- Insert into address table
INSERT INTO address (employee_id, street, city, state)
SELECT id, street, city, state
FROM JSON_TABLE(
  '{"employee": {"id": 1, "name": "John Doe", "department": "Sales", "address": {"street": "123 Main St", "city": "Anytown", "state": "CA"}}}',
  '$.employee'
  COLUMNS (
    id NUMBER PATH '$.id',
    street VARCHAR2(50) PATH '$.address.street',
    city VARCHAR2(50) PATH '$.address.city',
    state VARCHAR2(2) PATH '$.address.state'
  )
);&lt;/LI-CODE&gt;&lt;P&gt;This should help you get started!&lt;BR /&gt;Best regards,&lt;BR /&gt;florence0239&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 06:00:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-save-single-Json-data-to-multiple-Oracle-table/m-p/391673#M247721</guid>
      <dc:creator>florence0239</dc:creator>
      <dc:date>2024-08-13T06:00:35Z</dc:date>
    </item>
  </channel>
</rss>

