You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, when writing a query, you want to use a single parameter value in several places. Each placeholder being used exactly once is a limitation of the Moodle database system, which we just use as-is, so there is no easy way to do this.
There are tricks you can do. For examle with a single query that joins serveral tables, you can include something like
JOIN (SELECT :my_value AS my_value) input ON1=1
then you can refer to input.my_value everywhere. However, this is tricky to work out, and does not always work (e.g. with UNIONS).
In response to a question about this, I just relalised that we could implemented a work-around.
For example, we could make it that if you have parameters called :my_value, :my_value_copy1, :my_value_copy2, ..., then we only show a single input for 'my value' when someone runs the report, and then we duplicate that value as my_value_copy1, .... That should be feasible.
The text was updated successfully, but these errors were encountered:
timhunt
changed the title
Need an easy way to use the same parameter value repeatedly in a query
An easy way to use the same parameter value repeatedly in a query
Nov 19, 2021
Sometimes, when writing a query, you want to use a single parameter value in several places. Each placeholder being used exactly once is a limitation of the Moodle database system, which we just use as-is, so there is no easy way to do this.
There are tricks you can do. For examle with a single query that joins serveral tables, you can include something like
then you can refer to input.my_value everywhere. However, this is tricky to work out, and does not always work (e.g. with UNIONS).
In response to a question about this, I just relalised that we could implemented a work-around.
For example, we could make it that if you have parameters called :my_value, :my_value_copy1, :my_value_copy2, ..., then we only show a single input for 'my value' when someone runs the report, and then we duplicate that value as my_value_copy1, .... That should be feasible.
The text was updated successfully, but these errors were encountered: