From ODI 12c onwards we can load multiple tables with single mapping. In that case we need to make sure that which table need to be load first and next. For that we need to specify order.
- Open Mapping
- Go to Property Inspector as mentioned below:
From ODI 12c onwards we can load multiple tables with single mapping. In that case we need to make sure that which table need to be load first and next. For that we need to specify order.
In ODI, we have option of specify join order.
|
Scripts |
|
Source: [ { "id":
"0001", "type":
"donut", "name":
"Cake", "ppu":
0.55, "batters": { "batter": [ {
"id": "1001", "type": "Regular" }, {
"id": "1002", "type": "Chocolate" }, {
"id": "1003", "type": "Blueberry" }, {
"id": "1004", "type": "Devil's Food"
} ] }, "topping": [ {
"id": "5001", "type": "None" }, {
"id": "5002", "type": "Glazed" }, {
"id": "5005", "type": "Sugar" }, {
"id": "5007", "type": "Powdered
Sugar" }, {
"id": "5006", "type": "Chocolate with
Sprinkles" }, {
"id": "5003", "type": "Chocolate" }, {
"id": "5004", "type": "Maple" } ] }, { "id":
"0002", "type":
"donut", "name":
"Raised", "ppu":
0.55, "batters": { "batter": [ {
"id": "1001", "type": "Regular" } ] }, "topping": [ {
"id": "5001", "type": "None" }, {
"id": "5002", "type": "Glazed" }, {
"id": "5005", "type": "Sugar" }, {
"id": "5003", "type": "Chocolate" }, {
"id": "5004", "type": "Maple" } ] }, { "id":
"0003", "type":
"donut", "name":
"Old Fashioned", "ppu":
0.55, "batters": { "batter": [ {
"id": "1001", "type": "Regular" }, {
"id": "1002", "type": "Chocolate" } ] }, "topping": [ {
"id": "5001", "type": "None" }, {
"id": "5002", "type": "Glazed" }, {
"id": "5003", "type": "Chocolate" }, {
"id": "5004", "type": "Maple" } ] } ] |
|
Target DDL: CREATE TABLE "DEMO"."JSON_TABLE" ( "FILE_NAME" VARCHAR2(255 BYTE), "LOAD_DATE"
VARCHAR2(255 BYTE), "ID"
NUMBER(10,0), "NAME"
VARCHAR2(255 BYTE), "PPU"
NUMBER(10,2), "TYPE"
VARCHAR2(255 BYTE), "SEQ_NUM"
NUMBER(10,0), "BATTER_ID"
NUMBER(10,0), "BATTER_TYPE"
VARCHAR2(255 BYTE), "TOPPING_ID"
NUMBER(10,0), "SEQ_TOPPING"
NUMBER(10,0), "TOPPING_TYPE"
VARCHAR2(255 BYTE) ) |
|
begin
EXECUTE IMMEDIATE 'truncate table emp_hierarchy';
EXECUTE
IMMEDIATE 'truncate table emp_hi';
FOR
i IN (
SELECT
employee_id
FROM
hr.employees
ORDER BY
employee_id
)
loop
EXECUTE IMMEDIATE 'drop table employees';
EXECUTE IMMEDIATE 'create table employees
as select * from hr.employees where employee_id=' || i.employee_id;
EXECUTE IMMEDIATE 'truncate table
emp_hi';
INSERT INTO emp_hi
WITH cte (
employee_id,
first_name,
manager_id,
pos
) AS (
SELECT
employee_id,
first_name,
manager_id,
1 pos
FROM
employees
UNION ALL
SELECT
cte.employee_id,
mgr.first_name,
mgr.manager_id,
cte.pos + 1 pos
FROM
hr.employees mgr,
cte
WHERE
mgr.employee_id =
cte.manager_id
)
SELECT
employee_id,
first_name,
5 - pos pos
FROM
cte;
COMMIT;
INSERT INTO emp_hierarchy
SELECT
employee_id,
mgr_level4,
coalesce(mgr_level3, mgr_level4)
mgr_level3,
coalesce(mgr_level2, mgr_level3,
mgr_level4) mgr_level2,
coalesce(mgr_level1, mgr_level2,
mgr_level3, mgr_level4) mgr_level1
FROM
emp_hi PIVOT (
MAX ( first_name )
FOR pos
IN ( 4 mgr_level4, 3
mgr_level3, 2 mgr_level2, 1 mgr_level1 )
);
commit;
end loop;
END;
|