Let me share very important concept of ODI called using Variable as Resource name.Suppose if we have multiple files of same structure to be loaded into a single target table, then we need not to use multiple interfaces.Instead we can use a single interface to load all the flat files of same structure into the single target table.I am going to try to explain the procedure with following stepsSuppose if we have three Flat files namely EMP1.txt, EMP2.txt and EMP3.txt to be loaded into TRG_EMP table of ORACLE database.Before going to do this, you need to learn first how to load a single source flat file to a target table of oracle database.To do the above please go through the following link provided by oracle by examplesODI11g: Creating an ODI Project and Interface: Exporting a Flat File to a RDBMS Table
Using the above procedure load the EMP.txt file to
EMP table .
you can download the required files from the following link
Download source files
Now follow the following steps.
First we need to create a table using the following queryCREATE TABLE SRC_FILE_DETAILS( FILE_NAME VARCHAR2(10 BYTE));Then load the required file names into this table.INSERT INTO src_file_details values 'EMP1'INSERT INTO src_file_details values 'EMP2'INSERT INTO src_file_details values 'EMP3'Now create three variables with the following deatails1) Name: countData type: NumericAction : latest Value2) Name: Files_CountDatatype: NumericAction: latest ValueRefreshing: select count(*) from src_file_details3) Name: FILE_NAMEDatatype: AlphanumericAction: Latest valueRefreshing:SELECT FILE_NAME FROM (SELECT FILE_NAME,ROWNUM RN FROM SRC_FILE_DETAILS) WHERE RN=#Project_Name.countNote: Please replace Project_Name with your project nameNow open the source data store which is participating in the interface for populating target and replace the resource name with #Project_Name.FILE_NAME.txtNow we are going to design a package looks like below:
Step1:Drag and drop the count variable on to the diagram tab of package.Click on it. Change the properties as shown in the followingStep2: Drag and drop the FILE_NAME variable on to the diagram tab of package.Click on it. Change the properties as shown in the followingStep name: GetTheFileNameType: Refresh variableStep3:Just drag and drop the interface and change the step name to PopTrgWithThisFileNameStep4:Drag and drop the count variable.Click on it. Change the properties as shown in the following
Step5:Drag and drop the Files_Count variable.Click on it. Change the properties as shown in the followingStep type : Refresh VariableStep6:Drag and drop the count variable on to the diagram tab of package.Click on it. Change the properties as shown in the followingDrag and drop the Files_Count variable.Click on it. Change the properties as shown in the followingStep type : Refresh VariableStep6:Drag and drop the count variable on to the diagram tab of package.Click on it. Change the properties as shown in the following
Please replace Proj_Name with your project nameSave allRun the packageThat it.Now life is so easy.You can load a table with several files with single interface.
MULTIPLE FILES - SINGLE TARGET TABLE-SINGLE INTERFACE
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.