STRING_TRUNCATE_ERROR configuration parameter
Use the STRING_TRUNCATE_ERROR configuration parameter to request string truncation error -1279 for a non-ANSI database.
For databases operating in MODE ANSI, an attempt to insert (using DML statements INSERT, UPDATE, MERGE) CHAR, VARCHAR, NVARCHAR, NCHAR, or LVARCHAR strings that result in truncation will produce an error -1279 (Value exceeds string column length). Conversely, in non-ANSI databases, string truncation occurs automatically and silently, without generating an error. This silent truncation is the default behavior for non-ANSI databases. The STRING_TRUNCATE_ERROR configuration parameter can be utilized in non-ANSI databases to detect and capture instances of string truncation.
The ONCONFIG file value of STRING_TRUNCATE_ERROR applies to all non-ANSI databases. It is not relevant to MODE ANSI databases.
- onconfig.std value
- STRING_TRUNCATE_ERROR [0|1]
- values
-
- 0 = silent string truncation and SQL execution for non-ANSI databases
- 1 = raise an SQL error -1279 (Value exceeds string column length) for non-ANSI databases
If not set in the ONCONFIG file, the default will be 0 for backward compatibility.
- takes effect
- After you edit your onconfig file and restart the database server.
Usage
Given table specifies impact of STRING_TRUNCATE_ERROR on error handling in case of string truncation for a non-ANSI datbase.
| ONCONFIG value | For Non-ANSI database |
|---|---|
| UNSET | No error reported, silent truncation happens. |
| 0 | No error reported, silent truncation happens. |
| 1 | error -1279 |
There is an equivalent session environment variable STRING_TRUNCATE_ERROR . In sessions where the STRING_TRUNCATE_ERROR configuration parameter and the STRING_TRUNCATE_ERROR session environment variable have different settings, the session environment variable takes precedence for the duration of that session, or until the STRING_TRUNCATE_ERROR session environment variable is reset.