Anda di halaman 1dari 21

Module 7: A MultiLoad Application

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.

TCS Internal

New Accounts Application Description


New Account Information Customer details New Existing Transaction(s) Applied to Balance Added to History

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.

An Account can be opened for new or pre-existing customer(s) UPSERT to


the Customer table.

Each New Account will probably require an opening transaction UPDATE to


TCS Internal

Account (balance) and INSERT to Trans_History.

New Accounts Application Script (1 of 3)


.LOGTABLE Newacct_logtable_mld; .LOGON tdpid/username, password; .BEGIN IMPORT MLOAD TABLES Accounts, Account_Customer, Customer, Trans_Hist ; .LAYOUT New_Acc_Layout ; .FILLER in_Field_Indicator 1 CHAR(1) ; .FIELD in_Account_Number 2 INTEGER ; .FIELD in_Number * INTEGER ; .FIELD in_Street * CHAR(25) ; .FIELD in_City * CHAR(20) ; .FIELD in_State * CHAR(2) ; .FIELD in_Zip_Code * INTEGER ; .FIELD in_Balance_Forward * INTEGER ; .FIELD in_Balance_Current * INTEGER ; .FIELD .FIELD .FIELD .FIELD .FIELD .FIELD .FIELD .FIELD .FIELD TCS Internal .FIELD in_Customer_Number in_Last_Name in_First_Name in_Social_Security in_AC_Account_Number in_AC_Customer_Number in_Trans_Number in_Trans_Account_Number in_Trans_ID in_Trans_Amount 2 * * * 2 * 2 * * * INTEGER CHAR(25) CHAR(20) INTEGER ; ; ; ;

INTEGER ; INTEGER ; INTEGER INTEGER INTEGER INTEGER ; ; ; ;

New Accounts Application Script (2 of 3)


.DML LABEL Label_A ; INSERT INTO Accounts VALUES ( :in_Account_Number, :in_Number, :in_Street, :in_City ,:in_State, :in_Zip_Code, :in_Balance_Forward, :in_Balance_Current ) ; .DML LABEL Label_B ; INSERT INTO Account_Customer VALUES ( :in_AC_Account_Number, :in_AC_Customer_Number); .DML LABEL Label_C MARK MISSING UPDATE ROWS DO INSERT FOR MISSING UPDATE ROWS ; UPDATE Customer SET Last_Name = :in_Last_Name WHERE Customer_Number = :in_Customer_Number ; INSERT INTO Customer VALUES ( :in_Customer_Number, :in_Last_Name, :in_First_Name, :in_Social_Security ) ; .DML LABEL Label_D ; INSERT INTO Trans_Hist VALUES ( :in_Trans_Number, DATE, :in_Trans_Account_Number, :in_Trans_ID, :in_Trans_Amount ) ; UPDATE Accounts SET Balance_Current =Balance_Current + :in_Trans_Amount WHERE Account_Number =:in_Trans_Account_Number ; .IMPORT INFILE datain4 LAYOUT New_Acc_Layout APPLY Label_A WHERE (in_Field_Indicator = 'A' ) APPLY Label_B WHERE (in_Field_Indicator = 'B' ) APPLY Label_C WHERE (in_Field_Indicator = 'C' ) APPLY Label_D WHERE (in_Field_Indicator = 'D' ) ; .END MLOAD ;
TCS Internal

New Accounts Application Script (3 of 3)


.IF (&SYSINSCNT1 > 0 OR &SYSUPDCNT1 > 0) THEN; COLLECT STATISTICS ON Accounts; .ENDIF; .IF (&SYSINSCNT2 > 0) THEN; COLLECT STATISTICS ON Account_Customer; .ENDIF; .IF (&SYSINSCNT3 > 0 OR &SYSUPDCNT3 > 0) THEN; COLLECT STATISTICS ON Customer; .ENDIF; .IF (&SYSINSCNT4 > 0) THEN; COLLECT STATISTICS ON Trans_Hist; .ENDIF; .LOGOFF ;

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 " " " "

Note:
.BEGIN IMPORT MLOAD TABLES Accounts, Account_Customer, Customer, Trans_Hist ; 1st table
TCS Internal

2nd table

3rd table

4th table

.BEGIN IMPORT Task Commands


Specifies the tables and optionally the work and error tables used in this
MultiLoad job.

Also used to specify miscellaneous MultiLoad options such as checkpoint,


sessions, etc.
.BEGIN [IMPORT] MLOAD TABLES tname1, tname2, ... WORKTABLES wt_table1, wt_table2, ERRORTABLES et_ table1 uv_table1, et_ table2 uv_table2, ... ERRLIMIT errcount [errpercent] CHECKPOINT rate (Default 15 min.) SESSIONS limit (Default 1 per AMP + 2) TENACITY hours (Default 4 hours) SLEEP minutes (Default 6 minutes) AMPCHECK NONE | APPLY | ALL NOTIFY OFF | LOW | MEDIUM | HIGH . . . ; .END MLOAD ;
TCS Internal

Work Tables
IMPORT Task: WORKTABLES wt_table1, wt_table2,
.BEGIN parameters

DELETE Task: WORKTABLES wt_table1

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 ...;

The Error Tables are described on the next page.


TCS Internal

Error Tables
ERRORTABLES et_tab1 uv_tab1, et_tab2 uv_tab2, ...
.BEGIN parameters

Error table 1 (et)

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.

Error table 2 (uv)

Uniqueness violations Constraint errors Overflow errors on columns other than primary index

Example:

TCS Internal

.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 ...;

ERRLIMIT
ERRLIMIT ErrCount Without ERRPERCENT:
.BEGIN parameters

Specifies approximate number of data errors permitted during Acquisition. Does not count Uniqueness violations.

ERRLIMIT ErrCount ErrPercent With ERRPERCENT:

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%.
TCS Internal

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

In this example, a 30-minute time interval is specified.

Example 2:

CHECKPOINT 100000

In this example, a checkpoint after 100,000 input records is specified.

TCS Internal

More .BEGIN Parameters


SESSIONS SESSIONS 64 48
.BEGIN parameters

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. Internal OFF suppresses the notify option. TCS NOTIFY

Note: The MultiLoad manual specifies in detail which events are associated with each level.

More .BEGIN Parameters: AMPCHECK


AMPCHECK NONE | APPLY | ALL
.BEGIN parameters

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.

TCS Internal

DELETE Task Commands


Specifies the table and optionally the work and error tables used in this
MultiLoad Delete task.

Also used to specify miscellaneous MultiLoad options such as tenacity,


sleep, etc.
.BEGIN DELETE MLOAD TABLES tname1 WORKTABLES wt_table1 ERRORTABLES et_ table1 TENACITY hours SLEEP minutes NOTIFY OFF | LOW | MEDIUM | HIGH . . . ; .END MLOAD

(Default 4 hours) (Default 6 minutes)

TCS Internal

.LAYOUT Parameters INDICATORS


INDICATORS The INDICATORS contain bits that, when equal to 1, represent a null data field.
Physical Input Records Indicator Byte(s)

F1

F2

F3

MultiLoad .LAYOUT Definition

.LAYOUT Record_Layout INDICATORS;

TCS Internal

.FIELD and .FILLER


.FIELD fieldname { startpos datadesc } || fieldexp [ NULLIF nullexpr ] [ DROP {LEADING / TRAILING } { BLANKS / NULLS } [ [ AND ] {TRAILING / LEADING } { NULLS / BLANKS } ] ] ; .FILLER [ fieldname ] startpos datadesc ; .FIELD

Input fields supporting redefinition and concatenation.


Startpos Fieldexpr identifies the start of a field relative to 1. specifies a concatenation of fields in the format:

fieldname1 || fieldname2 [ || fieldname3 ]


The option DROP LEADING / TRAILING BLANKS / NULLS is applicable only to character datatypes, and is sent as a VARCHAR with a 2-byte length field. .FILLER
TCS Internal

Identifies data NOT to be sent to the Teradata database.

Redefining the Input Example



A bank loads daily transactions sequentially on a tape for batch processing by MultiLoad. An input data record might be an Add, Update or Delete, each of which has a different length and contains different fields, as illustrated:
Add New Account

A U D

PI PI PI

F1 F4 F5

F2

F3

Update Existing Account

Delete Inactive Account

TCS Internal

.LAYOUT .FILLER .FIELD .FIELD .FIELD .FIELD .FIELD .FIELD

Record_Layout ; trans_type PI F1 F2 F3 F4 F5

1 2 * * * 6 *

CHAR(1) ; INTEGER ; INTEGER ; CHAR(25) ; CHAR(20) ; CHAR(2) ; INTEGER ;

Note: FILLER data is not placed into ML work tables.

The .DML Command Options


Defines Labels along with Error Treatment conditions for one or more following INSERTs, UPDATEs or DELETEs to be applied under various conditions: .DML LABEL Labelname

MARK or IGNORE

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. TCS Internal

MARK | IGNORE MARK | IGNORE

DUPLICATE MISSING

[INSERT || UPDATE ] ROWS UPDATE DELETE


;

Whether or not to record duplicate or missing INSERT, UPDATE, OR DELETE rows into the UV_error_table and continue processing.

The .DML Command Options (cont.)


.DML LABEL Labelname

DO INSERT FOR [MISSING UPDATE] ROWS DO INSERT FOR MISSING UPDATE

Key statement that indicates an UPSERT. An SQL UPDATE followed by an SQL INSERT is required.

Example 1:

.DML LABEL Action1

DO INSERT FOR MISSING UPDATE ROWS;

The default for an UPSERT operation is to not mark missing update rows.

Example 1:

.DML LABEL Action2

MARK MISSING UPDATE ROWS DO INSERT FOR MISSING UPDATE ROWS;

TCS Internal

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.

MARK | IGNORE MARK | IGNORE

DUPLICATE MISSING

[INSERT || UPDATE ] ROWS UPDATE DELETE


;

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.

.LAYOUT parameters define the data format.

.DML commands define Labels and Error Treatment conditions for one or more operations.
You can use FastLoad or MultiLoad INMODs.

TCS Internal

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

ERRLIMIT 200000 5 CHECKPOINT 50000 SESSIONS 4


;

TENACITY 6

.END MLOAD ;
TCS Internal

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

ERRLIMIT 200000 5 CHECKPOINT 50000 SESSIONS 4 TENACITY 6


; .END MLOAD ;
TCS Internal

Anda mungkin juga menyukai