# gizmodel/sql/errors

Protocol representations have one owner; no diagnostic text classifies a failure.

```gizlang
import * as Errors from "gizmodel/sql/errors";
```

## Functions

### `sqlstate`

```gizlang
function sqlstate(error: DbError): string
```

The SQLSTATE code of ERROR.

Effects: fail, alloc.

### `oracleCode`

```gizlang
function oracleCode(error: DbError): i64
```

The Oracle error number of ERROR, or 0 when it has none.

Effects: fail, alloc.

### `sqlcodeOf`

```gizlang
function sqlcodeOf(error: DbError): i64
```

The SQLCODE of ERROR, as PL/SQL reports it.

Effects: fail, alloc.

### `messageNumber`

```gizlang
function messageNumber(text: string): i64
```

The number of a PL/SQL compile message: PLS-00201 is 201, "PL/SQL: ORA-00984: ..." is 984, other texts 0.

Effects: fail, alloc.

### `predefinedNumber`

```gizlang
function predefinedNumber(name: string): i64
```

The Oracle error number of a predefined exception (PL/SQL's STANDARD package), or 0.

Effects: fail, alloc.

### `conditionState`

```gizlang
function conditionState(name: string): string
```

The SQLSTATE a condition name stands for (PostgreSQL's names and Oracle's predefined ones).

Effects: fail, alloc.

### `postgresMessage`

```gizlang
function postgresMessage(error: DbError): string
```

PostgreSQL's text for ERROR when the engine words it as SQLite does (no such table, NOT NULL constraint failed); ""
for the rest. The engine's own texts stay: its callers match them (bind.giz), and other dialects show them.

Effects: fail, alloc.

### `oracleMessage`

```gizlang
function oracleMessage(error: DbError): string
```

The Oracle message text of ERROR (ORA-NNNNN), or "" when it has no Oracle number.

Effects: fail, alloc.

## Constants

### `SQLSTATE_DUPLICATE_PREPARED`

```gizlang
const SQLSTATE_DUPLICATE_PREPARED = "42P05"
```

The SQLSTATE of a prepared statement whose name is already in use.

### `SQLSTATE_EXCEPTION`

```gizlang
const SQLSTATE_EXCEPTION = "P0001"
```

The SQLSTATE of an exception that a program raised.

