Description:
I'm building a Retool application and facing challenges while trying to bind the value from a text input component (nameTowerInput
) to an SQL query. I intend to update a table (my_towers
) with the value entered in the text input.
Steps Taken:
- Created a text input component with the ID
nameTowerInput
. - Attempted to use the value from the text input in an SQL query to update a column in the
my_towers
table:
sqlCopy code
UPDATE my_towers
SET tower_name = '{{nameTowerInput.value}}'
WHERE id = {{localStorage.towerId}};
- Tried using parameterized SQL:
sqlCopy code
UPDATE my_towers
SET tower_name = ?
WHERE id = ?;
Binding the nameTowerInput.value
to the first placeholder and localStorage.towerId
to the second.
Issues Faced:
- Error indicating mismatch in the number of supplied parameters vs. expected:
"bind message supplies 1 parameters, but prepared statement "" requires 0"
- Error on data type mismatch:
"could not determine data type of parameter $1"
- When trying to directly select the value for debugging purposes:
sqlCopy code
SELECT '{{nameTowerInput.value}}' AS inputValue;
I received the "bind message" error again.
Additional Information:
- The value from the text input (
nameTowerInput.value
) is a string. - The
localStorage.towerId
is an integer. - When hardcoding the values in the SQL query, it works as expected. The issue arises only when trying to dynamically bind the text input value.
Questions:
- Is there a specific format or method to correctly bind the value from a text input component to an SQL query in Retool?
- Are there any known issues or quirks related to SQL parameter binding in Retool that I should be aware of?
- How can I ensure that the
nameTowerInput.value
is correctly interpreted as a string and not causing the data type mismatch?