25.09.2015 Views

Teradata Parallel Data Pump

Teradata Parallel Data Pump Reference - Teradata Developer ...

Teradata Parallel Data Pump Reference - Teradata Developer ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: <strong>Teradata</strong> T<strong>Pump</strong> Commands<br />

UPDATE Statement and Atomic Upsert<br />

.IMPORT INFILE Infilename LAYOUT Layoutname APPLY DMLlabelname;<br />

.END LOAD;<br />

Usage Notes - Atomic Upsert<br />

The syntax for Atomic upsert consists of an UPDATE statement and an INSERT statement<br />

separated by an ELSE keyword as follows:<br />

UPDATE ELSE INSERT ;<br />

<strong>Teradata</strong> T<strong>Pump</strong> inserts the ELSE keyword between the UPDATE and INSERT statements by<br />

itself, so the user should not enter it in the script. If the ELSE keyword is used in this context,<br />

<strong>Teradata</strong> T<strong>Pump</strong> will terminate with a syntax error.<br />

The and are operands for regular UPDATE and<br />

INSERT SQL statements, respectively. Only certain types of UPDATE and INSERT operands<br />

are valid in an Atomic upsert statement, and the operand parameters within a given upsert<br />

statement are subject to further constraints linking the update and insert parameters.<br />

When using the standard upsert feature, the primary index should always be fully specified for<br />

the UPDATE statement, just as for other DML in a <strong>Teradata</strong> T<strong>Pump</strong> script, so that the update<br />

can be processed as a one-AMP rather than an all-AMP operation. In addition, both the<br />

UPDATE and the INSERT of an upsert statement pair should specify the same target table,<br />

and the primary index value specified in the UPDATE's WHERE clause should match the<br />

primary index value implied by the column values in the INSERT. When processing an<br />

Atomic upsert statement, <strong>Teradata</strong> <strong>Data</strong>base will usually reject statements that fail to meet<br />

these basic upsert constraints and return an error, enabling <strong>Teradata</strong> T<strong>Pump</strong> to detect and<br />

handle constraint violations.<br />

Constraints considered to be basic to the upsert operation are:<br />

• SAME TABLE: The UPDATE and INSERT statements must specify the same table.<br />

• SAME ROW: The UPDATE and INSERT statements must specify the same row; that is, the<br />

primary index value in the inserted row must be the same as the primary value in the<br />

targeted UPDATE row.<br />

• HASHED ROW ACCESS: The UPDATE must fully specify the primary index, allowing the<br />

target row to be accessed with a one-AMP hashed operation.<br />

• Some of these restrictions concern syntax that is supported in UPDATE and INSERT<br />

statements separately but not when combined in an Atomic upsert statement. Restrictions<br />

not supported by the Atomic upsert feature that return an error if submitted to <strong>Teradata</strong><br />

<strong>Data</strong>base are:<br />

• INSERT... SELECT: Syntax not supported. The INSERT may not use a subquery to specify<br />

any of the inserted values. Note that support of this syntax is likely to be linked to support<br />

of subqueries in the UPDATE's WHERE clause constraints as described above, and may<br />

involve new syntax features to allow the UPDATE and INSERT to effectively reference the<br />

same subquery.<br />

• UPDATE-WHERE-CURRENT: Syntax not supported. The WHERE clause cannot use an<br />

updatable cursor to do what is called a positioned UPDATE. (It is unlikely that this syntax<br />

will ever be supported.) Note that this restriction does not prevent cursors from being<br />

190 <strong>Teradata</strong> <strong>Parallel</strong> <strong>Data</strong> <strong>Pump</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!