CREATE ERROR TABLE - Detailed in Teradata

It is possible to log errors for a table while performing DML operations.

Syntax:
CREATE ERROR TABLE FOR tbl_name;


tbl_name - Table name for which the error table needs to be created.

Example:

CREATE SET TABLE table_old(i INT, j VARCHAR(10));
INSERT table_old (1,'nnn');

CREATE SET TABLE table_new(i INT, j INT);
INSERT table_new SEL * FROM table_old; -- ERROR : Bad character in format


The above code results in error since type violation.
Now we are going to log the error by creating error table.

CREATE ERROR TABLE FOR table_new;
INSERT table_new SEL * FROM table_old LOGGING ALL ERRORS;


If you want to check the error code then,
SELECT etc_errorcode FROM et_table_new WHERE etc_errorcode <>0;


Output:
2621
(Code for Bad character in format)