Skip to main content

Datometry Documentation

Specify a Custom Error Code for Teradata

The SQL hint default_teradata_error_code lets you specify a Teradata error code that you choose to be returned by Hyper-Q. Typically, Hyper-Q returns the error code 3706 for most errors. In the example below the first SELECT statement uses default_teradata_error_code to specify a value of 9999, which is then returned in the resulting error message. The second SELECT statement does not specify a custom error code value and returns 3706.

SELECT
-- @dtm_default_teradata_error_code = 9999
1/0;
*** Failure 9999 DTM3103: Failed to run query on the underlying database: Error Message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Divide by zero error encountered. SQLSTATE IS: 22012, Backend Error Code: 8134, SQL State: 22012 (odbc_beta:453)
Statement# 1, Info =0
SELECT 1/0;*** Failure 3706 DTM3103: Failed to run query on the underlying database: Error Message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Divide by zero error encountered. SQLSTATE IS: 22012, Backend Error Code: 8134, SQL State: 22012 (odbc_beta:453)
Statement# 1, Info =0

The syntax for default_teradata_error_code is:

default_teradata_error_code=error_code 

where:

Parameter

Description

error_code

The value of the error you wish to assign. Error codes can be a numeric value ranging from 0-65535.

Example 40. Specify a Custom Error Code for Teradata for Individual SQL Statements

This example configures Hyper-Q to return an error code of 9999 as the default error code value. When specified in this manner, the hint applies only to the statement in the request where it is embedded.

CREATE TABLE table_name
-- @dtm_default_teradata_error_code=9999
(a int, b int);

To learn more about Hyper-Q SQL hints, and how to use them within a SQL query, see About Hyper-Q SQL Hints.



Example 41. Specify a Custom Error Code for the Duration of a Session

Using the for session hint, you can specify that default_teradata_error_code be used for the duration of a session, as opposed to for a single query.

CREATE TABLE table_name
-- @dtm_default_teradata_error_code=9999 for session
(a int, b int);

To learn more about Hyper-Q SQL hints, and how to use them within a SQL query, see About Hyper-Q SQL Hints.



Example 42. Specify a Custom Error Code Using the Hyper-Q Configuration File

You can configure a custom error code in the Hyper-Q configuration file. Doing so applies the configuration you specify globally for all queries using Hyper-Q. Add the configuration option to the gateway section of the Hyper-Q configuration file (dtm.ini).

Note

Your deployment may have multiple instances of Hyper-Q. The custom error code only applies to the Hyper-Q instances you configure with this hint.

"gateway".default_teradata_error_code=9999

To learn more about specifying a hint as a gateway option in the Hyper-Q configuration file, see Gateway Configuration Parameters.Gateway Configuration Parameters