Vous êtes sur la page 1sur 9

Teradata 13.

0
Converting Rows to Column Transformation

Description:
BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Guide for building financial data model in Teradata. The document focuses on how the real world requirement should be interpreted. The mapping document template alone with steps to implement and screen shots makes the complete learning so easy. The document focuses on how to identify the top n record from the data source and load into target system. Join our professional training program and learn from experts.

History:
Version 0.1 0.1 Description Change Initial Draft Review#1 Author Anil Tekam Amit Sharma Publish Date 12th Aug 2011 18th Aug 2011

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 1

Introduction Summary

This is one of document for identifying top 3 records. In this document we have performed the searching and loading operation with the help of fast export and fast load tools. In this document, first we have performed the searching operation with the help of fast export utility and then fast export created system generated output data file. This output file contains the data in the system understandable format. Then we use the fast load utility because this utility helps for loading the records into the target table.

Mapping sheet of Source to Target table(TRG_CREDIT):-

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 2

Step #1:-In this example, we search the top 3 records with the help of fast
export utility and then we load that top 3 records in the target table with the help of fast load utility. Now we are showing the two source table data and then we select the columns from both the table.

Select Top 3 Record and load them into target using Fast load: utility:

Second Source table (SRC_BRANCH_CD):- We will join both table's using


BRANCH_CD column.

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 3

Step #2:-Now we create the fast export flat file script. We have written the
select query in fast export script and this select query used to identify the top three records from the source table. 1.) BEGIN EXPORT STATEMENT. 2.) DEFINE THE OUTPUT FILE NAME. 3.) THE SELECT PULLS DATA FROM TABLE (SCR_CREDITCARD,SRC_BRANCH_CD). 4.) END THE JOB AND LOGOFF TERADATA.
/* ---------------------------------------------------------------*/ /* @(#) FASTEXPORT SCRIPT */ /* @(#) Version 1.1 */ /* @(#) Created by BISP Team */ /* ---------------------------------------------------------------*/ ALWAYS GOOD TO IDENTIFY THE SCRIPT AND AUTHOR IN COMMENTS

Step #3:-Now we execute this fast export flat file script in command prompt.

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

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 4

Step #5:-Now we are showing the output data file. This is the system
generated output data. This data only understand by the system.

Step #6 Now we create the fast load flat file script. This fast load utility
perform the loading operation into the target table. 1.) LOGIN ONTO TERADATA. 2.) DEFINING INPUT DATA FILE 3.) DEFINING THE ERROR FILES 4.) FAST LOAD PERFORM END LOADING. 5.) DEFINE LOGOFF CONNECTION
/* /* /* /* /* /* ++++++++++++++++++++++++++++ */ FASTLOAD SCRIPT TO LOAD THE */ Financial.SRC_CREDITCARD,SRC_BRANCH_CD*/ TABLE Version 1.1 */ Created by BISP Team */ ++++++++++++++++++++++++++++ */ Always good to identify the script and author in comment.

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 5

1.) LOGIN ONTO TERADATA:- we logon into the teradata fast load utility. 2.) DEFINING INPUT DATA FILE:- Now we comes the DEFINE statement. Fast load must know the structure and the name of the flat file to be used as the input flat file or source file for loading the data. 3.) DEFINING THE ERROR FILES:- In this script, there is no create table statement for the error tables. This error files work as error table. Fast load automatically
generate both error table. In this instance, they are named err1_tp and UV_tp table. First error table (err1_tp) contains only constraints based related error and second error table (UV_tp) contains only unique violation error.

4.) FAST LOAD PERFORM END LOADING:- The target table must be empty at the loading time and if the loading has completed, then we use the END LOADING statement. If we don't use the END LOADING statement then we get error i.e. Target table being loaded and that time we can't access the loading data. 5.) DEFINE LOGOFF CONNECTION:Now all the sessions has logoff. This is the last statement of this fast load script. Now the table lock has released and if no rows in the error table, then that error table automatically dropped and if there is any single row in error table then we check it, then we take appropriate action and drop that error table manually.

Step #7:-Now execute this fast load flat file script in command prompt. It will
take few second for successful execution.

Step #8:-This fast load flat file script has successfully executed and it has
generated output log file i.e. fload_top_log.txt.

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 6

Step #9:- Now we are showing the fast load output log file script. Fast load
utility generate the two phase after the successful execution of fast load flat file script. 1.)DEFINING LOGON CONNECTION. 2.)INSERT PHASE. 3.)END LOADING PHASE.

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 7

1.)DEFINING LOGON CONNECTION:- In this logon statement, we have successfully created the logon connection of fast load utility. 2.)INSERT PHASE:- In this insert phase, we have performed the DML operation i.e. insert operation. In this insert operation, we are sending all 3 records from system generated output data file (fexp_tp_data.txt) to target table i.e. TRG_CREDIT table. 3.)END LOADING PHASE:- In this END LOADING PHASE, we have completed the loading process into the target table. System has read total 3 records from output data file and now applied the insert operation in all 3 records. There is no error in error table 1 and error table 2. We can manually drop both the error

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 8

table from the database, where the error table place and we are not loading any duplicate rows then total duplicate rows is zero.

Step #10:- Now we are showing the data of target table i.e. TRG_CREDIT
Table. All the 3 rows has successfully inserted into the target table. We have used the fast load utility for loading the flat file data into target table. We can use this sql query for showing the result of target table.

Sql Query--> SELECT * FROM FINANCIAL.TRG_CREDIT;

www.bispsolutions.com www.bisptrainings.com

| |

www.hyperionguru.com Page 9

Vous aimerez peut-être aussi