6
Views
2
Comments
Solved
how can I know if a integer variable came with empty value?
Question

I'm retrieving information from a sql view for an API, but sometimes some columns have null values, so when I transform them in to a JSON format they key doesn't appear, but I want to make they appear as a default value, which I set as 0 or False in their corresponding case, but It still doesn't working.

Rank: #70
Solution

Hi Bruno,


If you're using Advanced SQL, you can use the ISNULL function to make sure, that you don't get nulls and get the 0.

Something like this:


The is null basically works like if field is not null, it retrieves the first attribute, otherwise the second.

Using this function forces the output of the query not to be null which is what you're trying to do.


Additionally, you can set the attributes of the structure you're deserializing to, to Mandatory so you force them to appear:


Hope it helps.


Regards,
João