---
name: "tdbc_mapSqlState"
section: "n"
platform: "linux"
package: "tcl"
version: "8.6.16-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/tdbc_mapSqlState/n"
---

# tdbc\_mapSqlState(n)

Map SQLSTATE to error class

```

```

## NAME

tdbc::mapSqlState - Map SQLSTATE to error class

## SYNOPSIS

```
package require tdbc 1.0
tdbc::mapSqlState sqlstate
```

```

```

## DESCRIPTION

The **tdbc::mapSqlState** command accepts a string that is expected to be a five-character 'SQL state' as returned from a SQL database when an error occurs. It examines the first two characters of the string, and returns an error class as a human- and machine-readable name (for example, **FEATURE\_NOT\_SUPPORTED**, **DATA\_EXCEPTION** or **INVALID\_CURSOR\_STATE**).

The TDBC specification requires database drivers to return a description of an error in the error code when an error occurs. The description is a string that has at least four elements: "**TDBC** *errorClass* *sqlstate* *driverName* *details...*". The **tdbc::mapSqlState** command gives a convenient way for a TDBC driver to generate the *errorClass* element given the SQL state returned from a database.

## SEE ALSO

[tdbc(n)](/tdbc/n.md), tdbc::tokenize, tdbc::connection(n), tdbc::statement(n), tdbc::resultset(n)

## KEYWORDS

TDBC, SQL, database, state

## COPYRIGHT

Copyright (c) 2009 by Kevin B. Kenny.
