DROP TEMPORARY VARIABLE
説明
DROP TEMPORARY VARIABLE ステートメントは、一時変数を削除します。変数が存在しない場合は例外がスローされます。
構文
DROP TEMPORARY { VAR | VARIABLE } [ IF EXISTS ] variable_name
パラメータ
-
variable_name
既存の変数の名前を指定します。関数名は、オプションで system.session または session で修飾できます。
構文: [ system. [ session.] ] variable_name
-
IF EXISTS
指定された場合、変数が存在しないときに例外はスローされません。
例
-- Create a temporary variable var1
DECLARE VARIABLE var1 INT;
-- Drop temporary variable
DROP TEMPORARY VARIABLE var1;
-- Try to drop temporary variable which is not present
DROP TEMPORARY VARIABLE var1;
[VARIABLE_NOT_FOUND] The variable `system`.`session`.`var1` cannot be found. Verify the spelling and correctness of the schema and catalog.
If you did not qualify the name with a schema and catalog, verify the current_schema() output, or qualify the name with the correct schema and catalog.
To tolerate the error on drop use DROP VARIABLE IF EXISTS. SQLSTATE: 42883
-- Drop temporary variable if it exists
DROP TEMPORARY VARIABLE IF EXISTS var1;