Does SQLpage support caching of CTE data for forms ? #219
-
Example rather than making a call for each form input is there a way of making one call storing the data than accessing that for form elements ? maybe I am missing something out as I am using a CTE query per input as I want to populate with existing values.
then
etc |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey ! The simplest way to do that is to just make one query per form field, which is fine most of the time: select 'form' as component;
select 'username' as name, username as value from users where user_id = $user_id;
select 'email' as name, email as value from users where user_id = $user_id; But it looks like you would like to avoid making one query per form field. select 'form' as component;
with user as (select * from users where user_id = $user_id),
fields as (
select 'username' as name, username as value from user
union all
select 'email', email from user
)
select name, value, name as placeholder, true as required
from fields; |
Beta Was this translation helpful? Give feedback.
-
Thanks, of course UNION, I imagine it is possible to create "select" types as well by creating a json() name, value pair within the SQL too. |
Beta Was this translation helpful? Give feedback.
Hey !
If I got it right, what you want is create a form that can be used to edit a record in a database table. You want each column in the table to be represented by a field in the form, and each field to be pre-filled with the current value of the column.
The simplest way to do that is to just make one query per form field, which is fine most of the time:
But it looks like you would like to avoid making one query per form field.
This is definitely possible, and does not need any special SQLPage feat…