-
-
Notifications
You must be signed in to change notification settings - Fork 162
run_sql parameters #1132
-
This has caught me out a few times - inclusion of parameters in the function call removes the ability to access the same variables as the calling page. Is this by design/as expected? The description of the function is slightly ambiguous and I initially interpreted it as passed parameters being additional to those available in the calling file.
E.g.
calling.sql
set test_var_1 = (select 1)
select 'text' as component, 'This is the calling file. Testing the variable: ' || $test_var_1 as contents;
select 'dynamic' as component, sqlpage.run_sql('include.sql', json_object('test_var_2', '2')) as properties;
include.sql
select 'text' as component, 'This is the inclusion file. Testing the variable: ' || $test_var_1 as contents;
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Yes, this is intentional.
You can use sqlpage.variables and merge existing variables with new ones, but I wouldn't recommend it. For future-proofing your code and making it easier to maintain and debug, it's usually better to explicitly name the parameters you are passing to run_sql.
Can you open a pull request with the changes you would like to see in the documentation to make it more explicit?
Beta Was this translation helpful? Give feedback.