Escolar Documentos
Profissional Documentos
Cultura Documentos
After completing this module, you will be able to: Describe the tables involved in a MultiLoad job. Set error limits as a time value or as a percentage of loaded rows. Specify a checkpoint interval. Redefine input record layout.
MULTILOAD
Accounts
A# UPI
Customer
C# UPI
Account_Customer
A# C# NUSI UPI
Trans_Hist
A# NUPI DATE
Each New Account requires an INSERT into the Accounts table and an INSERT
into Account_Customer.
MultiLoad environment variables can be checked to optionally COLLECT STATISTICS as part of the job.
&SYSDELCNT_ &SYSINSCNT_ &SYSUPDCNT_ &SYSETCNT_ &SYSUVCNT_ where _ is 1 to 5 " " " "
.LOGOFF ;
Note:
.BEGIN IMPORT MLOAD TABLES Accounts, Account_Customer, Customer, Trans_Hist ; 1st table 2nd table 3rd table 4th table
Work Tables
IMPORT Task: WORKTABLES wt_table1, wt_table2,
.BEGIN parameters
Default is in users default database and the work table is named WT_TableName. Alternative may be specified as DataBaseName.WorkTableName.
There must be one work table defined for each data table.
Example: .BEGIN [IMPORT] MLOAD TABLES Employee, PayCheck WORKTABLES util_db.WT_Emp ,util_db.WT_Pay ERRORTABLES util_db.ET_Emp util_db.UV_Emp ,util_db.ET_Pay util_db.UV_Pay ...;
Error Tables
ERRORTABLES et_tab1 uv_tab1, et_tab2 uv_tab2, ...
.BEGIN parameters
default is the users database and the table is named ET_Tablename. contains any errors that occur in the Acquisition Phase. contains primary index overflow errors that occur in the Application phase
default is the users database and the table is named UV_Tablename. contains Application Phase errors.
Uniqueness violations Constraint errors Overflow errors on columns other than primary index .BEGIN [IMPORT] MLOAD TABLES Employee, PayCheck WORKTABLES util_db.WT_Emp ,util_db.WT_Pay ERRORTABLES util_db.ET_Emp util_db.UV_Emp ,util_db.ET_Pay util_db.UV_Pay ...;
Example:
ERRLIMIT
ERRLIMIT ErrCount Without ERRPERCENT:
.BEGIN parameters
Specifies approximate number of data errors permitted during Acquisition. Does not count Uniqueness violations.
Specifies a percentage of data errors after an approximate number of records has been transmitted.
Example:
ERRLIMIT 10000 5
In this example, after processing 10,000 input records, the system looks for an error rate of 5%.
CHECKPOINT
Rate may be specified in the Acquisition Phase of a complex IMPORT task as:
.BEGIN parameters
A number of incoming records (exact count; not less than 60) A time interval in minutes (approximate; less than 60)
If no CHECKPOINT value is specified MultiLoad will checkpoint every 15 minutes, and at the end of each Phase. The default is 15 minutes.
Example 1:
CHECKPOINT 30
Example 2:
CHECKPOINT 100000
Used to specify the maximum, and optionally, minimum sessions generated by MultiLoad.
TENACITY
TENACITY 10
Number of hours MultiLoad will try to establish a connection to the system. The default is 4 hours.
SLEEP
SLEEP 3
Number of minutes MultiLoad waits before retrying a logon; must be greater than 0. The default is 6 minutes.
NOTIFY
NOTIFY OFF
NOTIFY LOW NOTIFY MEDIUM for the most significant events. NOTIFY HIGH for every MultiLoad event that involves an operational decision point. NOTIFY OFF suppresses the notify option.
Note: The MultiLoad manual specifies in detail which events are associated with each level.
NONE MultiLoad will not perform an AMPCHECK. It will proceed if AMPs are offline, provided all target tables are
FALLBACK.
APPLY MultiLoad will continue in all phases except the Application phase with
AMPs offline, provided all target tables are FALLBACK. This is the default.
ALL MultiLoad will not proceed with down AMPs, regardless of the
protection-type of the target tables. Most conservative option.
.TABLE The input fields are defined with the same name, data type, and order of an existing table.
Format: .LAYOUT layoutname CONTINUEIF position = variable INDICATORS tableref ; ;
.TABLE
the input record. Continuation Character Field is defined beginning in character position 1.
1 2 10 45 80
Y
Physical Input Records 1 2
F1
35
F2
F3
80
Record 1
N FILLER
MultiLoad .LAYOUT Definition
F5
Record 2
F1
F2
F3
FILLER
F5
F1
F2
F3
Example 2: .LAYOUT emp_record; .TABLE Employee; Note: Employee is an existing table whose column names and data descriptions are assigned, in the order defined, to fields of the input data records.
A U
PI PI
F1 F4 F5
F2
F3
PI
Record_Layout ; trans_type PI F1 F2 F3 F4 F5
1 2 * * * 6 *
DO INSERT FOR [MISSING UPDATE] ROWS Operation: INSERT (Duplicate violation) UPDATE (Duplicate violation) UPDATE (Fails - missing row) DELETE (Fails - missing row) UPSERT (If successful) UPSERT (Fails) Default:
Marked in UV_tablename Marked in UV_tablename Marked in UV_tablename Marked in UV_tablename Ignored Mark failure of INSERT in UV_tablename
Example of UPSERT failure: 1. PI value doesnt exist, so UPDATE cant occur. 2. INSERT fails because of check violation - e.g., cant put character data in a numeric field.
DUPLICATE MISSING
Key statement that indicates an UPSERT. An SQL UPDATE followed by an SQL INSERT is required.
Example 1:
The default for an UPSERT operation is to not mark missing update rows.
Example 1:
When the MARK MISSING UPDATE ROWS is used with an UPSERT, this will place (in the UV_table) data rows that cant be updated (no PI). If the insert also fails, the insert record is also marked in the UV_table.
DUPLICATE MISSING
MultiLoad Statistics
At the end of the application phase, MultiLoad provides statistical information.
****06:06:41 UTY1803 Import Processing Statistics Total Thus far 200000 200000
****06:18:34 UTY0818 Statistics for table ACCOUNTS: Inserts: 50000 Updates: 50000 Deletes: 0 ****06:18:35 UTY0818 Statistics for table ACCOUNT_CUSTOMER: Inserts: 50000 Updates: 0 Deletes: 0 ****06:18:35 UTY0818 Statistics for table CUSTOMER: Inserts: 25000 Updates: 25000 Deletes: 0 ****06:18:35 UTY0818 Statistics for table TRANS_HIST: Inserts: 50000 Updates: 0 Deletes: 0
INMODs
Data
MultiLoad
0
INMOD
Teradata
Valid data record in Buffer EOF not reached. Length field reflects correct length of output record. If an input record was supplied to the INMOD from MLOAD and is to be skipped, the length field should be set to zero. If no input record was supplied, setting the length to zero indicates EOF.
Non 0
0 1 0 1
2 3
Note: MultiLoad can also use the FastLoad INMOD return codes.
4 5 6 7
Summary
On the .BEGIN statement, optionally, the names of work and error tables can be specified. You can:
Specify error limits and checkpoints. Limit sessions. Designate time allowed for connection. Specify retry time limit. Designate the level of notification you prefer. Designate how MultiLoad will proceed if AMPs are offline.
.DML commands define Labels and Error Treatment conditions for one or more operations.
You can use FastLoad or MultiLoad INMODs.
Review Questions
1. Complete the BEGIN statement to accomplish the following:
Specify an error limit count of 200,000 and an error percentage of 5%. Specify a checkpoint at 50,000 records. Limit the sessions to 4. Set the number of hours to try to establish connection as 6.
.LOGTABLE RestartLog_mld; .LOGON ________________; .BEGIN [IMPORT] MLOAD TABLES Trans_Hist
TENACITY 6
.END MLOAD ;
Review Questions
1. Complete the BEGIN statement to accomplish the following:
Specify an error limit count of 200,000 and an error percentage of 5%. Specify a checkpoint at 50,000 records. Limit the sessions to 4. Set the number of hours to try to establish connection as 6.
.LOGTABLE RestartLog_mld; .LOGON ________________; .BEGIN [IMPORT] MLOAD TABLES Trans_Hist
SESSIONS 4
TENACITY 6
; .END MLOAD ;
Lab Exercises
Lab Exercise 7-1
Purpose In this lab, you will use MultiLoad to insert the data rows you deleted in a lab from Module 6. The Accounts, Trans, and Customer tables each should have 100 rows in them (from Lab 6-1). What you need Populated tables and macro AU.Lab7_1. Tasks 1. Export data to a file called data7_1 by executing the macro AU.Lab7_1. Submit the following commands in BTEQ: .EXPORT DATA FILE = data7_1; EXEC AU.LAB7_1; .EXPORT RESET; Note: The Trans_Date is exported with an ANSI Date Format of 'YYYY-MM-DD' and a data type of CHAR(10). 2. Prepare a MultiLoad script which inserts rows into one of three different tables using the redefinition feature of MultiLoad. The input record contains a mixture of records which are to be inserted into the Accounts table if the first record byte is an A, the Customer table if the first byte is a C and the Trans table if the first byte is a T. 3. Check your tables for 200 rows per table. Your MultiLoad job should have a final return code of zero and should evidence 100 rows inserted into each of the three tables.
Lab Exercises
Lab Exercise 7-2
Purpose In this lab, you will prepare and execute a MultiLoad script which performs an 'UPSERT' operation (INSERT MISSING UPDATE) on your Accounts table as a single operation. What you need Populated tables and macro AU.Lab7_2. Tasks 1. Delete all rows from the Accounts Table and use the following INSERT/SELECT to create 100 rows of data in your table. INSERT INTO Accounts SELECT * FROM AU.Accounts WHERE Account_Number LT 20024101 ; 2. Export data to a file data7_2 using the macro AU.lab7_2. .EXPORT DATA FILE = data7_2 ; EXEC AU.Lab7_2 ; .EXPORT RESET ; 3. Prepare and execute a MultiLoad script which performs an 'UPSERT' operation (INSERT MISSING UPDATE) on your Accounts table as a single operation. Use the data from data7_2 as input to the MultiLoad 'UPSERT' script. If the row exists, UPDATE the Balance_Current with the appropriate incoming value. If not, INSERT a row into the Accounts table. 4. Validate your results. MultiLoad should have performed 100 UPDATES and 100 INSERTS with a final return code of zero.
INSERT INTO Accounts VALUES (:in_accountno, :in_number, :in_street, :in_city, :in_state, :in_zip_code, :in_balancefor, :in_balancecur); .IMPORT INFILE data7_2 LAYOUT Record_Layout_723 APPLY Fix_Account; .END MLOAD; .LOGOFF; mload < lab723.mld > lab723.out