Skip to content

Commit 0a58582

Browse files
committed
improve run_sql documentation
1 parent 57681a5 commit 0a58582

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

examples/official-site/sqlpage/migrations/38_run_sql.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ select ''dynamic'' as component, sqlpage.run_sql(''common_header.sql'') as prope
3131
- **variables**: the included file will have access to the same variables (URL parameters, POST variables, etc.)
3232
as the calling file.
3333
If the included file changes the value of a variable or creates a new variable, the change will not be visible in the calling file.
34+
35+
### Parameters
36+
37+
You can pass parameters to the included file, as if it had been with a URL parameter.
38+
For instance, you can use:
39+
40+
```sql
41+
sqlpage.run_sql(''included_file.sql'', json_object(''param1'', ''value1'', ''param2'', ''value2''))
42+
```
43+
44+
Which will make `$param1` and `$param2` available in the included file.
45+
[More information about building JSON objects in SQL](/blog.sql?post=JSON%20in%20SQL%3A%20A%20Comprehensive%20Guide).
3446
'
3547
);
3648
INSERT INTO sqlpage_function_parameters (

0 commit comments

Comments
 (0)