Sei sulla pagina 1di 9

Multi Load Utility Loading Data from Flat File to Target Table

Description: BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a list of beginners guide and FAQs for Teradata learners. Download many such learning documents, student guide, Lab Guide and Hands-on practice materials.. Join our professional training to learn from Experts.

www.bispsolutions.com

www.bisptrainings.com 1

Introduction:This is one of our documents for transforming data from flat file to target table using FAST EXPORT, BTEQ, and MULTI. Summary:In this Multi Load utility, we load the flat file data in the target table. We use the fast export utility for taking the data from source. That data exist in flat file is to be loaded into target tables with the help of multi load utility. Fast Export tool is useful tool for generating the multi load input flat file. The fast export utility generates the output in encrypted form. We have also used another tool i.e. BTEQ utility, it can be used for all the DML operation (i.e. INSERT/UPDATE/DELETE/SELECT). Mapping sheet of Source to Target This is the detail of input flat file and target table.

Steps to Load Data from source to target


Step #1:-In this multi load utility, we load the flat file data in the target table. We have shown the target database i.e. Financial and target table i.e. SRC_ACCOUNT_OFFICER_CD.

www.bispsolutions.com

www.bisptrainings.com 2

Step #2:- Fast Export Script is as given below.


1) 2) 3) 4) BEGIN EXPORT STATEMENT. SESSIONS 2; DEFINES THE OUTPUT FILE NAME. THE SELECT PULLS DATA FROM TABLE (Financial.Src_Account_Officer_CD). END THE JOB AND LOGOFF TERADATA ALWAYS GOOD TO IDENTIFY THE SCRIPT AND AUTHOR IN COMMENTS

/* ---------------------------------------------------------------*/ /* @(#) FASTEXPORT SCRIPT */ /* @(#) Version 1.1 */ /* @(#) Created by BISP Team */ /* ---------------------------------------------------------------*/

Step #3:-Now execute this fast export flat file script in command prompt. This fast export flat file script will take few second for successful execution. After the successful execution it will generate some text file or flat file. We have written the execution command of fast export utility.

www.bispsolutions.com

www.bisptrainings.com 3

Step #4:-This fast export flat file has successfully executed and it has generated output flat file script.

Step #5:- The output data flat file script (flat_SRC_data.txt) is as below. This output data is in encrypted form. This output flat file data will use by multi load input flat file script for loading the target table.

Step #6:- This multi load input flat file has been generated after the execution of fast export script. This script shows multi load utility. i) Sets Up a Logtable and Logs on to Teradata. ii) Invoke Import iii) Define both Target Tables Target Tables Need to Work Tables Target Tables Need for Error Table iv) LAYOUT defines the format of the INPUT DATA record so Teradata knows what to expect. Names the LAYOUT of the INPUT record and defines its structure; Notice the dots before the FIELD and FILLER and the semi-colons after each definition. v) Tells MultiLoad to INSERT a row into the target table and defines the row format.

www.bispsolutions.com

www.bisptrainings.com 4

vi) vii)

Names the Import File and its Format type; Cites the LAYOUT file to use tells Mload to APPLY the INSERTs. Ends MultiLoad and Logs off all MultiLoad sessions

Step One: Setting up a Logtable and Logging onto Teradata MultiLoad requires you specify a log table right at the outset with the .LOGTABLE command. We have called it LOGTABLE095911. Once you name the Logtable, it will be automatically created for you. The Logtable may be placed in the same database as the target table, or it may be placed in another database. Immediately after this you log onto Teradata using the .LOGON command. The order of these two commands is interchangeable, but it is recommended to define the Logtable first and then to Log on, second. If you reverse the order, Teradata will give a warning message. Notice that the commands in MultiLoad require a dot in front of the command key word.

www.bispsolutions.com

www.bisptrainings.com 5

Step Two: Identifying the Target, Work and Error tables In this step of the script you must tell Teradata which tables to use. To do this, you use the .BEGIN IMPORT MLOAD command. Then you will preface the names of these tables with the sub-commands TABLES, WORKTABLES AND ERROR TABLES. All you must do is name the tables and specify what database they are in. Work tables and error tables are created automatically for you. Keep in mind that you get to name and locate these tables. If you do not do this, Teradata might supply some defaults of its own! At the same time, these names are optional. If the WORKTABLES and ERRORTABLES had not specifically been named, the script would still execute and build these tables. They would have been built in the default database for the user. The name of the worktable would be WT_SRC_ACCOUNT_OFFICE_CD and the two error tables would be called ET_ SRC_ACCOUNT_OFFICE_CD and SRC_ACCOUNT_OFFICE_CD, respectively. Step Three: Defining the INPUT flat file record structure MultiLoad is going to need to know the structure the INPUT flat file. Use the .LAYOUT command to name the layout. Then list the fields and their data types used in your SQL as a .FIELD. Did you notice that an asterisk is placed between the column name and its data type? This means to automatically calculate the next byte in the record. It is used to designate the starting location for this data based on the previous fields length. The LAYOUT name will be referenced later in the .IMPORT command. If the input file is created with INDICATORS, it is specified in the LAYOUT. Step Four: Defining the DML activities to occur The .DML LABEL names and defines the SQL that is to execute. It is like setting up executable code in a programming language, but using SQL. In our example, MultiLoad is being told to INSERT a row into the SQL01.Employee_Dept table. The VALUES come from the data in each FIELD because it is preceded by a colon (:). Are you allowed to use multiple labels in a script? Sure! But remember this: Every label must be referenced in an APPLY clause of the .IMPORT clause. Step Five: Naming the INPUT file and its format type Using the .IMPORT command, we have identified the INFILE data as being contained in a file called flat_src_data.txt. Step Six: Finishing loading and logging off of Teradata This is the closing ceremonies for the load. MultiLoad to wrap things up, closes the curtains, and logs off of the Teradata system. Step #7:-Now we have executed this multi load flat file script in command prompt After the successful exaction it will generate the output log file.

Step #8:-Now after the execution of multi load flat file script , it has generated one multi load output log file.

www.bispsolutions.com

www.bisptrainings.com 6

Step #9:-Show the detail information of multi load output log file script. This script is showing the Logon/connection it means that connection has done successfully.

In this script all 24 record has imported from flat file to target table successfully. These 24 records stored in the output data file (flat_SRC_data.txt). In Multi Load Task Cleanup phase contains the error table and at that time this two error tables is error free.

www.bispsolutions.com

www.bisptrainings.com 7

In this script Multi load Task has successfully completed and data has loaded in the target table. After that we have closed the connection using the .Logoff keyword.

www.bispsolutions.com

www.bisptrainings.com 8

Step #10:-The final result is shown below. In this multi load flat file data has inserted from flat file to target table. Use this query for showing the result of multi load utilitySQL Query:- SELECT * FROM FINANCIAL.SRC_ACCOUNT_OFFICER_CD; In this task we have successfully loaded or imported data from flat file to target table. We have used fast export utility, BTEQ and Multi Load utility.

www.bispsolutions.com

www.bisptrainings.com 9

Potrebbero piacerti anche