tdbc::mapSqlState(3tcl)

✨ NAME ✨

tdbc::mapSqlState β€” bestie, this is the little glow-up that turns a SQLSTATE into an error class πŸ’…


🌸 SYNOPSIS 🌸

package require tdbc 1.0

tdbc::mapSqlState sqlstate

πŸ’– DESCRIPTION πŸ’–

Okay so. The tdbc::mapSqlState command takes a string, and that string is supposed to be a five-character 'SQL state' β€” you know, the thing a SQL database hands you when something goes wrong 😭.

It peeks at the first two characters of that string, and gives you back an error class. And not just any error class β€” a human- and machine-readable name. Like, for example, FEATURE_NOT_SUPPORTED, DATA_EXCEPTION or INVALID_CURSOR_STATE. Iconic, honestly ✨

Here's the lore: the TDBC specification says database drivers have to return a description of an error in the error code whenever an error happens. And that description is a string with at least four elements, laid out like this:

TDBC errorClass sqlstate driverName details...

So the tdbc::mapSqlState command is literally the convenient little hack for a TDBC driver to cook up that errorClass element, given the SQL state the database handed back 🫢


πŸ¦‹ SEE ALSO πŸ¦‹

  • tdbc(3tcl)
  • tdbc::tokenize
  • tdbc::connection(3tcl)
  • tdbc::statement(3tcl)
  • tdbc::resultset(3tcl)

πŸŽ€ KEYWORDS πŸŽ€

TDBC, SQL, database, state β€” the whole vibe check πŸ‘‘


Copyright (c) 2009 by Kevin B. Kenny.


And that's the whole page, bestie! This one lives in the Tcl corner of the tdbc::mapSqlState(3tcl) manual, sitting pretty at Tcl 8.6 β€” no cap, that's the version and section, go off πŸ’…βœ¨

πŸ“¦ where this page comes from