Friday 28 October 2011

Loading the data from flatfile to Oracle destination without using Dataflow Task:


By using SQL Loader Utility we can send the flat file data to Oracle destination

Step1: first we need Create Batch file with extension “.bat” in following location
          C:\
         -Open notepad and write below command
                Sqlldr  %1 %2 %3 %4 %5 %6
               @echo off
         -Save as Data.bat
        -in the above command
             1 –Database credentials(server name, user id, password).
             2 –Control File(ex:d:\control files\abc.ctl)
             3-Data File(d:\input.txt)
             4-Log File(d:\logs\abc.log)
             5-Discard file(d:\discard\abc.dsc)
             6-Bad File(d:\bad\abc.bad)
Step2: Preparation of Control file
           OPTIONS (READSIZE=20971520, BINDSIZE=20971520, ROWS=20000)
           LOAD DATA
           APPEND INTO TABLE EMPLOYEE

            FIELDS TERMINATED BY  ‘,’
            TRAILING NULLCOLS
            (
               ID INTEGER EXTERNAL NULL IF (ID=BLANKS),
               NAME CHAR NULL IF (NAME=BLANKS),
               SALARY INTEGER EXTERNAL NULL IF (SALARY=BLANKS)
             )

Note: if u want to skip the Header &Trailer use below script after ‘APPEND’
         WHEN (01:06)<>’HEADER’ and (01:07)<>’TRAILER’
Step3: Create Package
         -Drag Execute Process task into control flow
          -Right click--edit--click on process
            in executable  Specify batch file  i.e. C:\Data.bat
            In Arguments:
                                   “servername,scott/tiger”
                                   “control= d:\control files\abc.ctl”
                                   “data= d:\input.txt”
                                   “log= d:\discard\abc.log”
                                   “discard= d:\discard\abc.dsc”
                                   “bad= d:\discard\abc.bad”

   And click [OK] and execute the package.

No comments:

Post a Comment

SSIS: Creating Package Configurations

This post discusses the creation of Configuration Files and how they can be useful while migrating a package from one environment to an...