How to send null values to query from text box

Hi all,

I am trying to create a form where I need to run a pgsql procedure based on some values via a form and some values can be optional as well so I want to send NULL for those values but it shows error that says invalid integer value β€œβ€"" something like that, I tried to convert textbox type to number as well but no success

I need to do something like similar to case statement in query in retool

CASE WHEN {{txtZIP.value}} IS NOT NULL THEN {{txtZIP.value}} ELSE NULL END

I am unable to find anything like this in retool any idea will be appriciated.

Thanks
Cheers

Hey @wmg91 welcome to the Retool forum! Thanks for posting.

I think I follow what you’re asking, but if I’m off please share some more details or a screenshot of your issue.

You should be able to do this all inside {{ }} with some quick JS. Something like this might work:

CASE WHEN {{ txtZIP.value == "" }} THEN {{ txtZIP.value }} ELSE NULL END

Everything inside {{ }} is JS so when txtZIP.value is the empty string "" then {{ txtZIP.value == "" }} will evaluate to true and your first case will return. LMK if that works!

This is the error which I see without the case statements

Query Error (fn_land_search_new): invalid input syntax for type integer: ""

image

I've textbox input like the image attached

This is how I am sending value of textbox to query {{txtZIP.value}}

Now in case the textbox is empty I want to send NULL to query

2 Likes

A post was split to a new topic: Conditional filters in query