Skip to content

Commit 33e932e

Browse files
committed
Revert "fix comments"
This reverts commit 3473888.
1 parent 65395c9 commit 33e932e

File tree

4 files changed

+78
-180
lines changed

4 files changed

+78
-180
lines changed

docs/en/guides/54-query/08-stored-procedure.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,83 @@ A stored procedure is a set of executable commands or logic blocks stored within
66

77
## Supported Languages
88

9-
**Databend currently supports [SQL Scripting](/sql/sql-reference/sql-scripting) only**. Using SQL scripting, users can define procedures with control flow constructs like loops (FOR, WHILE, REPEAT) and conditionals (IF, CASE), enabling complex logic and effective multi-step operations.
9+
**Databend currently supports [SQL Scripting](#sql-scripting) only**. Using SQL scripting, users can define procedures with control flow constructs like loops (FOR, WHILE, REPEAT) and conditionals (IF, CASE), enabling complex logic and effective multi-step operations.
10+
11+
### SQL Scripting
12+
13+
In Databend, stored procedures support a rich set of features to allow users to define complex operations through SQL scripting. Here are the supported capabilities:
14+
15+
- **Variable Declaration**: Variables can be declared using the `LET` keyword, followed by the variable name, an optional type, and the initial value.
16+
17+
```sql title='Examples:'
18+
LET x := 100;
19+
```
20+
21+
- **Query Execution**: SQL queries can be executed within the script, and results can be stored in variables or result sets.
22+
23+
```sql title='Examples:'
24+
LET result RESULTSET := SELECT * FROM t1;
25+
```
26+
27+
- **Control Flow Constructs**
28+
- **FOR Loop**: Iterates over a range or a result set.
29+
30+
```sql title='Examples:'
31+
FOR i IN 1..10 DO ... END FOR;
32+
```
33+
34+
- **WHILE Loop**: Executes a block of code as long as a specified condition is true.
35+
36+
```sql title='Examples:'
37+
WHILE condition DO ... END WHILE;
38+
```
39+
40+
- **REPEAT Loop**: Executes a block of code until a condition is met.
41+
42+
```sql title='Examples:'
43+
REPEAT ... UNTIL condition END REPEAT;
44+
```
45+
46+
- **LOOP**: Executes a block of code indefinitely until a `BREAK` statement is encountered.
47+
48+
```sql title='Examples:'
49+
LOOP ... END LOOP;
50+
```
51+
52+
- **CASE Statement**: Allows conditional execution of code blocks based on different conditions.
53+
54+
```sql title='Examples:'
55+
CASE [operand]
56+
WHEN condition1 THEN ...
57+
WHEN condition2 THEN ...
58+
ELSE ...
59+
END;
60+
```
61+
62+
- **IF Statement**: Executes a block of code based on a condition.
63+
64+
```sql title='Examples:'
65+
IF condition THEN ...
66+
ELSEIF condition THEN ...
67+
ELSE ...
68+
END IF;
69+
```
70+
71+
- **RETURN**: Returns from the script with an optional value.
72+
73+
```sql title='Examples:'
74+
RETURN [expr];
75+
```
76+
77+
- **RETURN TABLE**: Returns from the script with a table result.
78+
79+
```sql title='Examples:'
80+
RETURN TABLE(result_set_name | SELECT ...);
81+
```
82+
83+
- **Comments**
84+
- **Single-line comments**: `-- comment`
85+
- **Multi-line comments**: `/* comment */`
1086

1187
## Limitations
1288

docs/en/sql-reference/00-sql-reference/98-sql-scripting.md

Lines changed: 0 additions & 108 deletions
This file was deleted.

docs/en/sql-reference/10-sql-commands/00-ddl/18-procedure/create-procedure.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ LANGUAGE <language>
1717
AS $$
1818
BEGIN
1919
<procedure_body>
20-
RETURN <return_value>; -- Use to return a single value
21-
-- OR
22-
RETURN TABLE(<select_query>); -- Use to return a table
20+
RETURN <return_value>;
2321
END;
2422
$$;
2523
```

docs/en/sql-reference/10-sql-commands/50-administration-cmds/execute-immediate.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)