# CHAPTER 8: Error Messages

## 8.1 Static SQL Compile-time Error Messages

The following is a list and brief descriptions of the Static SQL compile-time error messages:

`Cannot build mx qualification`

  The context specified in a `WHERE` clause could not be constructed.

`Command line too long`

  An SQL command line has exceeded the maximum length of 2048 characters.

`Cursor name limited to 128 characters`

  You have declared a cursor with a name exceeding the 128 character maximum.

`Cursor was not declared`

  You have attempted to open a cursor that was not declared.

`Data type not supported by `FETCH INTO` statement`

  You have attempted to use a variable of a type not supported by the SQL Precompiler.

`Errors`

  An error has occurred during precompilation.

`Invalid size for character variable`

  A character variable (i.e., a character array) has been declared with an index greater than 14 digits.

`Missing character variable length`

  The index value has been left out of a character variable (i.e., array) declaration.

`Missing `EXEC SQL BEGIN DECLARE` section`

  An `EXEC SQL END DECLARE SECTION` has been encountered before an `EXEC SQL BEGIN DECLARE SECTION`.

`Missing `EXEC SQL END DECLARE` section`

  No `EXEC SQL END DECLARE SECTION` was found in your program to match an `EXEC SQL BEGIN DECLARE SECTION`.

`Missing or out of place `EXEC SQL INCLUDE SQLCA``

  You have not included `EXEC SQL INCLUDE SQLCA` as the first executable Precompiler statement in your program.

`Multiple cursor declaration`

  You have declared a cursor with a name that has been previously declared.

`Multiple declaration of character variable`

  A character variable has been declared with a previously declared name.

`Numbers of attributes and variables do not match`

  The number of attributes do not match the number of values specified in a `FETCH`, `INSERT` or `SELECT INTO` statement.

`Syntax error`

  A syntax error has occurred in a SQL command line.

`Syntax error in declaration section`

  A syntax error has been made in the section of your Precompiler program. This may be a language specific error or a Precompiler error.

`Undeclared variables:`

  You have attempted to use a variable that has not been declared for Precompiler use.

`Update not allowed in multi-tables join`

  You have attempted to perform an update operation on a complex join.

`Variable name too long`

  A variable has been declared the name of which exceeds the maximum of 128 characters.

`Variables maximum`

  You have exceeded the maximum number of variables, 256, that can be declared for Precompiler use.

## 8.2 Static SQL Run-time Error Messages

The following is a list and brief descriptions of the runtime error messages:

`(-0)` | `Open table failed`
| Empress is unable to open the specified table.
`(-1)` | `Invalid WHERE clause (msmp_api_getbegin() or msmp_api_srtbeg() error )`
| You have specified an invalid `WHERE` clause.
`(-2)` | `Record cannot be deleted`
| Empress is unable to delete the record specified.
`(-3)` | `Conversion error during insert (msmp_api_putvs() or msmp_api_putvi() error)`
| You attempted to insert a value of the wrong data type.
`(-4)` | `Cursor not active`
| You have attempted to use a cursor that has not been opened.
`(-5)` | `Cannot add record`
| Empress cannot add the specified record to the table.
`(-6)` | `Cannot begin transaction`
| Empress cannot begin the specified transaction. This is likely due to the presence of a currently active transaction.
`(-7)` | `Cannot update record`
| Empress cannot update the specified record.
`(-8)` | `Conversion error during update (msmp_api_putvs() or msmp_api_putvi() error)`
| You attempted to update to a value of the wrong data type.
`(-10)` | `Read error`
| Failure when retrieving a record from a table, usually in the case of record is being locked. This error message is related to the following statements: `EXEC SQL SELECT` statment `EXEC SQL FETCH` statement `EXEC SQL UPDATE` statement
`(-11)` | `Call procedure failed`
| Failure when building of expressions and qualifications with the `EXEC SQL CALL` procedure.
`(-12)` | `Set value failed`
| Failure when building of expressions and qualifications with `EXEC SQL :var = expr` statement.
`(-13)` | `Conflict with already opened cursor`
| You try to open a table which is already associated to an opened cursor. This error message is related to the following statements: `EXEC SQL OPEN cursor` `EXEC SQL OPEN_TABLE table_name` `EXEC SQL UPDATE` `EXEC SQL DELETE` `EXEC SQL SELECT`
`(-14)` | `Close table failed`
| You try to close a table with `EXEC SQL CLOSE TABLE table_name` statement, but either the database or table does not exist, or table is not openned.
`(-15)` | `Empress initialization failed`
| Failure in the execution of initialization procedures, `EXEC SQL INIT`.
`(-16)` | `Invalid database`
| Failure to find a physical database in the statement `EXEC SQL DATABASE IS database_name`.

## 8.3 Dynamic SQL Error Messages

The following is a list of the runtime error messages for dynamic SQL. These messages are returned by `SQLERRMC`. The numbers in parentheses are the error codes returned by `SQLCODE`.

`(-60)` | `Undefined prepared statement name`
| Your `EXECUTE` command refers to a statement name which has not been defined by a `PREPARE` statement. Or you are attempting to open a cursor which is declared for a statement name which has not been defined.
`(-61)` | `Incorrect number of actual parameters`
| The number of variables in your `USING` clause is not equal to the number of parameters in the prepared statement.
`(-62)` | `Invalid `PREPARE` statement`
| Your `PREPARE` statement refers to a variable which is a `NULL` pointer.
`(-63)` | `Overflow of table of prepared statements`
| You attempted to prepare more than 200 statements in a program.
`(-64)` | `Wrong data type in `USING` clause`
| A variable in the `USING` clause has a data type which is not recognized.
`(-65)` | `Error detected by the SQL processor:`
| Your SQL statement could not be executed. The error message supplied by the SQL processor is usually appended to this message. The usual causes are syntax errors, or attempts to access table and/or attribute which do not exist. It may also happen if the database or the table is locked.
`(-66)` | `Attempt to execute a `SELECT` statement`
| Queries cannot be performed with the `EXECUTE` command.
`(-67)` | `Signal caught during execution of a dynamic statement`
| The execution of the SQL statement was aborted because the processor received a signal.
`(-68)` | `Unidentified error detected during execution of dynamic statement`
| The SQL statement could not be executed for an unknown reason. Check if you specified a valid database.
`(-69)` | `Overflow of table of declared cursors`
| You attempted to declare more than 200 cursors in a program.
`(-70)` | `Attempt to redefine a cursor`
| You attempted to declare a cursor using a cursor name which is already declared.
`(-71)` | `Attempt to open a previously opened cursor`
| You are not allowed to open a cursor which is already opened. You must close the cursor first, before re-opening it.
`(-72)` | `Open cursor error`
| The execution of the SQL `SELECT` statement associated with this cursor failed. This can be caused by syntax errors, invalid database, or tables and/or attributes which do not exist. It may also happen if the database or the table is locked.
`(-73)` | `Close cursor error`
| You attempted to close a cursor which was not opened.
`(-74)` | `Wrong number of variables/descriptor areas in `FETCH` statement`
| The number of variables or active areas in the descriptor specified in the `INTO` clause is not equal to the number of selected items in the query.
`(-75)` | `Unsupported array base type`
| The data type of the elements of the array variable is not supported.
`(-76)` | `Wrong type of variable in `FETCH`/`GET DESCRIPTOR` statement`
| A variable in the `GET DESCRIPTOR` statement or the `INTO` clause of the `FETCH` statement has a data type which is not recognized.
`(-77)` | `Internal conversion error`
| Empress could not perform the conversion between the internal data type of the attribute or selected item and the data type of the C variable.
`(-78)` | `Attempt to update/delete from a cursor opened in read mode`
| By default, a cursor is declared for read-only. To be able to update or delete records using the cursor, you need to declare the cursor for `UPDATE` or `DEFERRED` mode, or you can explicitly open the table in one of these modes.
`(-79)` | `Cursors used in `UPDATE`/`DELETE` must be made up of a single table`
| If a cursor is based on a `SELECT` statement which accesses more than one table, you are not allowed to update or delete records using this cursor.
`(-80)` | `Wrong table name in `UPDATE`/`DELETE` statement`
| The table name that you specified in the `UPDATE` or `DELETE` statement is not in the `SELECT` statement used to define the cursor.
`(-81)` | `Use of a cursor containing an aggregate function in `UPDATE`/`DELETE``
| You cannot update or delete records using a cursor based on a `SELECT` statement which contains an aggregate function.
`(-82)` | `Internal error detected while executing a `DELETE` statement`
| Empress could not delete the specified record. This could be caused by referential constraints on the table.
`(-83)` | `Wrong attribute name in `UPDATE` statement`
| You are attempting to update an attribute using a cursor which does not select this attribute.
`(-84)` | `Failed `UPDATE` statement`
| Empress could not update the specified record. This could be caused by referential constraints or unique indices on the table.
`(-85)` | `Wrong data type of variable in `UPDATE` statement`
| A variable in the `UPDATE` statement has a data type which is not recognized.
`(-86)` | `Overflow of table of allocated descriptors`
| You attempted to allocate more than 200 descriptors in a program.
`(-87)` | `Attempt to reallocate a descriptor`
| You attempted to allocate a descriptor using a descriptor name which already exists.
`(-88)` | `Use of a deallocated descriptor`
| You are attempting to use a descriptor which has been deallocated.
`(-89)` | `Wrong statement name`
| You attempted to describe a descriptor for a statement name which has not been defined by a `PREPARE` statement.
`(-90)` | `Descriptor contains fewer areas than required`
| The descriptor that you are using to describe a statement contains fewer areas than the number of parameters (for input) or the number of selected items (for output).
`(-91)` | `Descriptor must be associated with current cursor`
| You attempted to fetch using a descriptor which was not described for the statement associated with this cursor.
`(-92)` | `Wrong specification of descriptor area`
| You attempted to access an area which is invalid for this descriptor.
`(-93)` | `Attempt to update an output descriptor`
| You cannot assign values to fields in a descriptor which was described for output.
`(-94)` | `Invalid descriptor in `GET DESCRIPTOR` statement`
| You attempted to access a descriptor which is not valid for this operation.
`(-95)` | `Wrong data type of variable in `GET DESCRIPTOR` statement`
| A variable in the statement has a data type which is not valid for the field being accessed.
`(-96)` | `Output descriptor used in `EXECUTE`/`OPEN` statement`
| You attempted to use an output descriptor in the `USING` clause of a `EXECUTE` or `OPEN` statement. You should use an input descriptor instead.
`(-97)` | `Descriptor has not been prepared for specified statement`
| You attempted to `EXECUTE` a statement or `OPEN` a cursor or `FETCH` using a descriptor which was not described for the corresponding statement.
`(-98)` | `Input descriptor used in `FETCH` statement`
| You attempted to use an input descriptor in the `FETCH` statement. You should use an output descriptor instead.
`(-99)` | `Attempt to use an inactive cursor`
| You attempted to access a cursor which is not open.
`(-100)` | `Attempt to open a cursor based on a non-`SELECT` statement`
| You are attempting to open a cursor declared for a SQL statement which is not a `SELECT` statement.
`(-101)` | `Attempt to describe a statement with no parameters`
| You attempted to describe for input a prepared statement which does not contain parameters.
`(-102)` | `Ambiguous `DESCRIBE OUTPUT`: two or more opened cursors are based on the same statement`
| You are attempting to describe for output a statement which has more than one opened cursor associated with it. Empress does not know which cursor the descriptor should be associated with.