Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sql-ref-syntax-aux-set-var.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ SELECT var1, var2;

-- Too many rows
SET VAR (var1, var2) = (SELECT c1, CAST(c1 AS STRING) FROM VALUES(1), (2) AS t(c1));
Error: ROW_SUBQUERY_TOO_MANY_ROWS
[ROW_SUBQUERY_TOO_MANY_ROWS] More than one row returned by a subquery used as a row. SQLSTATE: 21000

-- No rows
SET VAR (var1, var2) = (SELECT c1, CAST(c1 AS STRING) FROM VALUES(1), (2) AS t(c1) WHERE 1=0);
Expand Down
11 changes: 11 additions & 0 deletions docs/sql-ref-syntax-ddl-declare-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ DECLARE [ OR REPLACE ] [ VARIABLE ]
-- The dense form of declaring a variable with default
DECLARE five = 5;

-- Declare a defined variable
DECLARE five = 55;
[VARIABLE_ALREADY_EXISTS] Cannot create the variable `system`.`session`.`five` because it already exists.
Choose a different name, or drop or replace the existing variable. SQLSTATE: 42723

-- Use `DECLARE OR REPLACE` to declare a defined variable
DECLARE OR REPLACE five = 55;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of DECLARE OR REPLACE does not exist in the doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to double check, the doc does mention it but we don't show it in the example, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this doc mentions it in the Syntax section, but don't show it in the example.
image


-- Explicitly declare the default value of a variable using the keyword `DEFAULT`
DECLARE VARIABLE size DEFAULT 6;

-- STRING variable initialialized to `NULL`
DECLARE some_var STRING;
```
Expand Down
7 changes: 4 additions & 3 deletions docs/sql-ref-syntax-ddl-drop-variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ DROP TEMPORARY VARIABLE var1;

-- Try to drop temporary variable which is not present
DROP TEMPORARY VARIABLE var1;
Error: VARIABLE_NOT_FOUND
The variable `system`.`session`.`var1` cannot be found.
[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 temporart variable if it exists
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo
temporart -> temporary

-- Drop temporary variable if it exists
DROP TEMPORARY VARIABLE IF EXISTS var1;
```

Expand Down