Sei sulla pagina 1di 14

Source description: SQL> desc emp_src; Name Null?

Type ----------------------------------------- -------- -------------EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB_TEST VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) Data to be insert: INSERT INTO EMP_SRC VALUES(7654,'MARTIN','SALESMAN',7698,'28/09/1981',1250,1400,30); INSERT INTO EMP_SRC VALUES(7698,'BLAKE','MANAGER',7839,'1/5/1981',2850,NULL,30); INSERT INTO EMP_SRC VALUES(7782,'CLARK','MANAGER',7839,'9/6/1981',2450,NULL,10); INSERT INTO EMP_SRC VALUES(7788,'SCOTT','ANALYST',7566,'9/12/1982',3000,600,20); INSERT INTO EMP_SRC VALUES(7839,'KING','PRESIDENT',NULL,'17/11/1981',5000,NULL,10); INSERT INTO EMP_SRC VALUES(7844,'TURNER','SALESMAN',7698,'8/9/1981',1500,0,30); INSERT INTO EMP_SRC VALUES(7876,'ADAMS','CLERK',7788,'12/1/1983',1100,NULL,20); INSERT INTO EMP_SRC VALUES(7900,'JAMES','CLERK',7698,'3/12/1981',950,NULL,30); INSERT INTO EMP_SRC VALUES(7902,'FORD','ANALYST',7566,'3/12/1981',3000,400,20); INSERT INTO EMP_SRC VALUES(7934,'MILLER','CLERK',7782,'23/01/1982',1300,NULL,10); INSERT INTO EMP_SRC VALUES(7903,'Sudipta','DBA',123,'22/01/2011',2000,NULL,NULL); INSERT INTO EMP_SRC VALUES(111,'POTTER','CLERK',7902,'17/12/1990',800,NULL,20); Target description: SQL> desc emp_tgt; Name Null? Type ----------------------------------------- -------- ----------------EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB_TEST VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE

SAL COMM DEPTNO

NUMBER(7,2) NUMBER(7,2) NUMBER(2)

Source data:

Description: (m_ Case1) Employee records should appear with lowest paid employee at the top and highest paid at the bottom. If salary between two employees is equal then the employee with lower comm should appear first (highlighted). Implementation: The mapping will be like below

The logic that has to be implemented in sorter transformation will be

The result set will be

Description: (m_ Case2) Update the target table to double salary of only Clerical employees who have joined (HireDate) in January month. Implementation: The mapping will be like below

In the above mapping expression transformation is used to double the salary in case of clerical employees who joined in the month of January.

Update transformation is used to update the data of clerical employees who joined in the month of January.

The result set will be

Description: (m_ Case3) Truncate the target table and populate it with employees drawing max salary for each deptno. Implementation: The mapping will be like below

In sorter transformation we have to mention DEPTNO as in ascending order and SAL in descending order

In expression transformation we have to compare the deptno and salary and then we have to assign the flag value

Then we have to take filter transformation to filter the rows based on flag value

The result set will be

Description: (m_ Case4) Truncate the target table and populate it with top two salary holder of each deptno. Implementation: The mapping will be like below

In sorter transformation we have to mention DEPTNO as in ascending order and SAL in descending order

In expression transformation we have to compare the deptno and salary and then we have to assign the flag value

Then we have to take filter transformation to filter the rows based on flag value

The result set will be

Description: (m_ Case5) Truncate the target table and populate it with deptno as a value increasing by 2 for each succeeding record as shown below. Implementation: The mapping will be like below..

The logic that has to be implemented in Expression transformation will be

Where, take a variable port to implement required logic The result set will be

Description: (m_ Case6) Truncate the target table and populate it with ENAME field as Concatenation of ENAME and DNAME (from attached File) with delimeter ~. Implementation: The mapping will be like below..

In the above mapping joiner transformation is used to join the data from two heterogeneous sources

Then take an expression transformation to concatenate the two columns ENAME AND DNAME

Connect it to target The result set will be

Description: (m_ Case7) Create a mapping with following flat files as source to generate a target file. Target file should have only those employees whose deptno is absent in Src_dept.dat file. Implementation: The mapping will be like below..

In the above mapping look up is used to check whether the data is matched in the Src_dept file or not

Expression transformation is used to create the flag value based on the result of lookup transformation

FLAG = IIF ( DEPTNO =DEPTNO1, 0, 1 )


Filter transformation is used filter the rows based on flag value

The result set will be

#EMPNO,ENAME,JOB_TEST,MGR,HIREDATE,SAL,COMM,DEPTNO 7654,"MARTIN","SALESMAN",7698,"28-SEP-81",1250,"1400",50 7844,"TURNER","SALESMAN",7698,"08-SEP-81",1500,"0",70 7903,"Sudipta","DBA",123,"22-JAN-11",2000,, Description: (m_ Case8) Target File should have details of only those deptnos whose total salary of employees is more than 7000. Implementation: The mapping will be like below..

Aggregator transformation is used to get the sum(sal) based on each group

Sorter transformation is used to sort the source data based on deptno because joiner transformation accepts only sorted input in above scenario.

Joiner is used join the data based on deptno

Filter transformation is used to filter the data based required condition


TOTAL_SAL > 7000

The result set will be #DEPTNO,TOTAL_SAL,DNAME 10,8750,"ACCOUNTING" 20,7900,"RESEARCH" Description: (m_ Case9) Create a mapping with following flat file as source to generate 3 different target files (one for each dept).Employee Names should be changed to Init Cap in each file. Implementation: The mapping will be like below

In the above mapping expression transformation is used to convert the first letter of the employee name to capital by using initcap function

Router transformation is used segregate the data based on deptno

The result set will be Dept10 #EMPNO,ENAME,JOB_TEST,MGR,HIREDATE,SAL,COMM,DEPTNO 7782,"Clark","MANAGER",7839,"09-JUN-81",2450,,10 7839,"King","PRESIDENT",,"17-NOV-81",5000,,10 7934,"Miller","CLERK",7782,"23-JAN-82",1300,,10 Dept20 #EMPNO,ENAME,JOB_TEST,MGR,HIREDATE,SAL,COMM,DEPTNO 7788,"Scott","ANALYST",7566,"09-DEC-82",3000,"600",20 7876,"Adams","CLERK",7788,"12-JAN-83",1100,,20 7902,"Ford","ANALYST",7566,"03-DEC-81",3000,"400",20 111,"Potter","CLERK",7902,"17-DEC-90",800,,20 Dept30 #EMPNO,ENAME,JOB_TEST,MGR,HIREDATE,SAL,COMM,DEPTNO 7654,"Martin","SALESMAN",7698,"28-SEP-81",1250,"1400",30 7698,"Blake","MANAGER",7839,"01-MAY-81",2850,,30 7844,"Turner","SALESMAN",7698,"08-SEP-81",1500,"0",30 7900,"James","CLERK",7698," 03-DEC-81",950,,30

Potrebbero piacerti anche