Start of change

-206   object-name IS NOT VALID IN THE CONTEXT WHERE IT IS USED

Explanation

An object is specified in a context where it is not valid.

object-name
The name of the object that could not be resolved.

Possible reasons for this error include:

  • The specified name is not a column of any of the source or target tables or views of the statement.
    • In a SELECT or DELETE statement, the specified name is not a column of any of the tables or views that are identified in a FROM clause in the statement.
    • In an INSERT, UPDATE, or MERGE statement, the specified name is not a column of the table, or view that was specified as the target of the data change statement.
    • A column list of an SQL data change statement specified a name that is not a column of the target table or view of the statement.
  • A qualified column name was specified, but the table designator that is specified as the qualifier is not defined in this context.
  • A correlated reference to a column was specified in an OLAP specification. Each column name that is referenced in an OLAP specification must unambiguously reference a column of the result table of the subselect that contains the OLAP specification.
  • The specified period is not a period of any of the source or target tables or views of the statement.
  • The target of an assignment clause of an SQL data change statement specified a name that is not a column of the target table or view of the statement, or an INCLUDE column defined for the statement. For a DELETE statement, the target of an assignment clause can only be an INCLUDE column.
  • The source of an assignment clause of an SQL data change statement referenced an INCLUDE column in an expression. A column defined in an INCLUDE clause can only be specified as the target of an assignment in an SQL data change statement.
  • A correlated reference to a column was specified for a grouping expression, which is not allowed.
  • A column defined in the INCLUDE clause of an UPDATE or DELETE statement was referenced in the WHERE clause of that statement.
  • The specified name is a correlated column reference in a subselect, which is not allowed.
  • A VALUES clause of an SQL data change statement specified the name of a column of the target table, which is not allowed.
  • For a CREATE or ALTER FUNCTION statement, or a CREATE or ALTER PROCEDURE statement:
    • The specified name does not resolve to the name of a column or variable.
    • The specified name resolves to the name of a variable that is not available in the current scope.
    • The specified condition name name specified in the SIGNAL statement has not been declared.
  • For a CREATE TRIGGER statement:
    • A reference is made to a name using an OLD or NEW correlation name for a transition variable. The name is not defined as a column in the triggering table.
    • The target of an assignment in the triggered action specified an old transition variable that is not valid for the type of trigger.
    • The referenced name does not resolve to the name of a column or variable.

System action

The statement cannot be processed.

Programmer response

Verify the following items:

  • For a SELECT statement:
    • Ensure that all the required tables are specified in the FROM clause.
    • Verify that all of the required tables or views were named in the FROM clause. If the name was intended to be a correlated reference to a column, qualify the name with the correct table designator.
    • For a subselect in an ORDER BY clause, ensure that there are no correlated column references.
  • For a DELETE statement, ensure that columns that are defined in the INCLUDE clause are specified only as targets of assignments.
  • For a CREATE FUNCTION, ALTER FUNCTION, CREATE PROCEDURE or ALTER PROCEDURE statement, ensure that:
    • The specified name resolves to the name of a column or variable.
    • The specified name resolves to the name of a variable that is available in the current scope.
    • The specified condition name name specified in the SIGNAL statement has been declared.
  • For a CREATE TRIGGER statement, ensure that:
    • The target of an assignment in a SET transition-variable statement specifies only new transition variables. Any reference to columns of the triggering table, including those that are contained in the top-level query block in the WHEN clause search condition, are qualified with a transition variable correlation name.
    • The top-level query block in the WHEN clause search condition contains only transition variables or transition table correlation names.

SQLSTATE

42703

End of change