---
title: INVALID_VARIABLE_DECLARATION error condition
description: Documentation for the INVALID\_VARIABLE\_DECLARATION error condition on Databricks
canonical_url: https://docs.databricks.com/gcp/en/error-messages/invalid-variable-declaration-error-class
---

# INVALID\_VARIABLE\_DECLARATION error condition

[SQLSTATE: 42K0M](https://docs.databricks.com/gcp/en/error-messages/sqlstates.md#class-42-syntax-error-or-access-rule-violation)

Invalid variable declaration.

## NOT\_ALLOWED\_IN\_SCOPE

Declaration of the variable `<varName>` is not allowed in this scope.

## ONLY\_AT\_BEGINNING

Variable `<varName>` can only be declared at the beginning of the compound.

## QUALIFIED\_LOCAL\_VARIABLE

The variable `<varName>` must be declared without a qualifier, as qualifiers are not allowed for local variable declarations.

## REPLACE\_LOCAL\_VARIABLE

The variable `<varName>` does not support `DECLARE` OR `REPLACE`, as local variables cannot be replaced.

## TABLEREF\_CONFLICTS\_WITH\_TEMP\_OBJECT

Cannot declare session `TABLEREF` variable `<varName>` because a temporary view or table with the same name exists.

## TABLEREF\_DEFAULT\_NOT\_SUPPORTED

`DEFAULT` values are not supported for `TABLEREF`.

## TABLEREF\_EXECUTE\_IMMEDIATE\_NOT\_SUPPORTED

`TABLEREF` variables cannot be used as targets of `EXECUTE IMMEDIATE INTO`.

## TABLEREF\_INVALID\_SOURCE

`TABLEREF` variables can only be assigned table identifiers (for example, schema.tableName), not expressions or query results.

## TABLEREF\_MULTIPLE\_ASSIGNMENT

Cannot assign multiple variables when using `TABLEREF`. Only one `TABLEREF` variable can be set at a time.

## TABLEREF\_NOT\_INITIALIZED

`TABLEREF` variable `<varName>` has not been initialized. Assign a table to it before using it in a query.

## TABLEREF\_NOT\_NULL\_NOT\_SUPPORTED

`NOT NULL` is not supported on `TABLEREF` declarations.
