I have a query called getTotalRows
which contains something like this:
SELECT COUNT(p.id) as total_rows
FROM
products p
INNER JOIN
stores s ON p.store_id = s.id
INNER JOIN
countries c ON p.country_id = c.id
WHERE
(
c.name ILIKE '%' || COALESCE({{Countryy.value}}, '') || '%'
)
AND (
p.name ILIKE '%' || COALESCE({{Name.value}}, '') || '%'
)
AND (
s.shop_name ILIKE '%' || COALESCE({{Shop.value}}, '') || '%'
)
and in retool there is a failure feature to run something if the query times out or fails
and I want if the getTotalRows query times out or fails then the total_rows will be 1000++
how do you do it or what is the javascript code?
Thank You
Hello Nico,
I would try to create a variable and if successful save the data in the variable and i itf fails save whatever you want.
@Rati_Bakhtadze
makes sense,
umm but, may you give me a little example?
@Nico_Revaldo Hi Nico, I would be happy to share with you an example. It would be helpful to know exactly what you would like to record. For instance, are you trying to keep a tally of the total number of times that a query fails, or something else?
You can create a variable by selecting "variable" from the "Code" menu in the left pane. Name your variable so you can easily reference it in your SQL query event handler. You can optionally set an initial value or just leave it as null. In the "Failure" event handler of your query, choose "Set variable" as the action and choose your variable under "State". Finally, the "Value" field is where you would add the logic of what should be stored. If you are just keeping a tally and incrementing then you would add something like:
{{ myVar.value++ }}
Let me know if you have any questions!