Hello everyone,
I'm working on a project where I'm trying to update a PostgreSQL table with data selected from a List Collection component. Here's a brief overview of what I'm trying to achieve and the challenges I'm facing:
Objective:
- I have a List Collection (
listCollection2
) in my Retool app that displays different tower garden types. - When a user selects a specific tower garden from this collection, I want to update a row in my
my_towers
table in PostgreSQL with the details of the selected tower garden.
What I've Tried:
- I used the following SQL query to achieve this:
sqlCopy code
UPDATE my_towers
SET tower_type = '{{listCollection2.selectedRow.tower_garden}}',
ports = {{listCollection2.selectedRow.ports}}
WHERE id = {{localStorage.towerId}};
However, this resulted in the error: "could not determine data type of parameter $1".
2. To debug the data type, I hard-coded the values and ran:
sqlCopy code
UPDATE my_towers
SET tower_type = 'TestType',
ports = 1234
WHERE id = 17;
This query ran successfully and updated the database as expected, indicating that the issue might be with how I'm accessing the data from listCollection2
.
Also ran:
return listCollection2.data[0].tower_garden;
That worked. Of course you cant hard code that...
Questions:
- How can I correctly access the selected row's data from the List Collection component to use in my SQL query?
- Are there specific properties or methods associated with the List Collection component that I should be using to achieve this?
Any insights or suggestions would be greatly appreciated. Thank you in advance!