sqlpage.set_variable(name, value)
Introduced in SQLPage 0.40.0.
Returns a URL that is the same as the current page's URL, but with a variable set to a new value.
This function is useful when you want to create a link that changes a parameter on the current page, while preserving other parameters.
It is equivalent to sqlpage.link(sqlpage.path(), json_patch(sqlpage.variables('get'), json_object(name, value))).
Example
Let's say you have a list of products, and you want to filter them by category. You can use sqlpage.set_variable to create links that change the category filter, without losing other potential filters (like a search query or a sort order).
select 'button' as component, 'sm' as size, 'center' as justify;
select
category as title,
sqlpage.set_variable('category', category) as link,
case when $category = category then 'primary' else 'secondary' end as color
from categories;
Parameters
name(TEXT): The name of the variable to set.value(TEXT): The value to set the variable to. IfNULLis passed, the variable is removed from the URL.
Parameters
name
The name of the variable to set.
value
The value to set the variable to.
basic_auth_password
basic_auth_username
client_ip
cookie
current_working_directory
environment_variable
exec
fetch
fetch_with_meta
hash_password
header
headers
hmac
link
path
persist_uploaded_file
protocol
random_string
read_file_as_data_url
read_file_as_text
request_body
request_body_base64
request_method
run_sql
set_variable
uploaded_file_mime_type
uploaded_file_name
uploaded_file_path
url_encode
user_info
user_info_token
variables
version