Set boolean to null...

Set boolean to null...

  
Hi everyone,

I reached a problem and I wondering if it's possible...
I'm developing a combobox which contains three expressions and I need to set a boolean combobox with 3 states, a null value, True value , False value.
Is there any possibility to pass a null value to a boolean or there is a workaround for that?
After that i need to pass a variable to SQL.

Cheers,

Bruno Santos
Hi Bruno,

You should set the special list with:
Value 1: 0
Option 1: null
Value 2: 1
Option 2: True
Value 3: 2
Option 3: False

Then you define a variable type integer and set the combobox Special Variable with that integer variable.
Hi Diogo,

thanks for your reply,

i've done something similiar, but the problem is when I receive the integer variable , must set the condition to a boolean var and there don't allow me to set a null value. Only agree to be set or True or False....

Cheers,

Bruno Santos
Hi Bruno,

But bool values doesnt have null. just 1 or 0.
You want to save null on DB boolean value?
Hi Diogo,

No, I have a variable input Parameter to do a query from a DB, to show if the item is true, false or to show them all.

Cheers,

Bruno Santos
Ok.

You can set the input query as the result of special variable (integer), then you make the condition
WHERE SpecialVariable = 0 or (SpecialVariable = 1 and ResultSet.IsActive = 1) or   (SpecialVariable = 2 and ResultSet.IsActive = 0) 
 Hello,

In fact there is no null value for booleans. What i suggest you to do is the following:


Set a special list value
on the combobox  for example -1 for null value (-).
on the action, use a if statement to build a expand inline like:
                       if ( selectedcomboboxvalue <> -1)

                              build a expandinline like: {table}.[booleanvalue] = @value

Use a advanced query and send the Expandinline to it.
Means that it
should only include on the adv query the statement if not null.

i hope it helps,
Luis Paulo Soares


Bruno Santos wrote
:
Hi everyone,

I reached a problem and I wondering if it's possible...
I'm developing a combobox which contains three expressions and I need to set a boolean combobox with 3 states, a null value, True value , False value.
Is there any possibility to pass a null value to a boolean or there is a workaround for that?
After that i need to pass a variable to SQL.

Cheers,

Bruno Santos
 
Guys, 

you don't need to use advanced queries neither expand inline parameters for this :)

Simple queries are not so simple as they seem to be. Take a look at my last year next step presentation where I explain how to use this situation Page 32.

Or you can download Vacation app from Service Studio 6.+ to copy the code

Cheers, 
RNA
Hello,

Thats true but if you want the field as mandatory the special values doesnt count (they are all non mandatory even if u select one), also the OR condition in a SQL Query is inefficient because it have to validate the rule for every record (row) which make it more inefficient!! Also simple querys return a lot of output tables.

Advanced querys with expandinline is the best and most efficient way in my opinion.

Best regards,
Luis Paulo Soares
Luís, 

just a quick note. Simple queries are optimized to return only the attributes used in the screen, they don't return a lot of output tables.

Please take a look at "Automatic Performance Optimizations" in the demo session @ http://www.outsystems.com/demos to see the built-in performance features that the platform does.

Concerning to performance, you can also use isSearch parameter to use only the condition you actually use in the where clause. Go simple, it will turn your code much more readable for who maintain, and the platform does the optimization for you.

Cheers, 
RNA
Ricardo Araújo wrote:
Luís, 

just a quick note. Simple queries are optimized to return only the attributes used in the screen, they don't return a lot of output tables.

Please take a look at "Automatic Performance Optimizations" in the demo session @ http://www.outsystems.com/demos to see the built-in performance features that the platform does.

Concerning to performance, you can also use isSearch parameter to use only the condition you actually use in the where clause. Go simple, it will turn your code much more readable for who maintain, and the platform does the optimization for you.

Cheers, 
RNA
 
If you are creating 1 more statement in the where clause means your are making one more restrition/row when you dont need really need it since its all rows you really want! Each restrition takes time to validade... What Outsystems does or not i dont know because i dont like to let Outsystems control what i consider is better.

You can always try create the querys on SQL Server based on huge loads of data with the both cases and compare. The restritions you are saying and without the restritions (for all cases) or with only the restrition that you really need and check the performance time...
Luís, 

not exactly. As I said, if you use isSearchParameter option you'll only have one where clause condition.

You should take a look for more details on isSearch Paramater take a look @ http://www.outsystems.com/help/servicestudio/6.0/default.htm#Using_Data/Simple_Query_Parameter_Properties.htm

The simple query have more "power" to build an application then people are used to see them. It's very commom to find people using advanced queries when simple queries do the job. Go Simple. For a bettrer knowledge  

About " What Outsystems does or not i dont know because i dont like to let Outsystems control what i consider is better." Please take a look @ http://www.outsystems.com/help/servicestudio/6.0/default.htm#Using_Data/Define_Simple_Queries.htm and find what the platform does. The platform is not the Devil, and is built highly focus on performance.
lpsoares wrote:
 
If you are creating 1 more statement in the where clause means your are making one more restrition/row when you dont need really need it since its all rows you really want! Each restrition takes time to validade... What Outsystems does or not i dont know because i dont like to let Outsystems control what i consider is better.
 
 Hi Luis,

Ricardo's statement on the Search Parameter dropping the condition altogether is correct: if you enable it on a parameter and the expression passed in evaluates (once!) to the platform's null value for that variable type ("" for Text, 0 for Integer, False for Boolean) then that statement will not be part of the WHERE section of the SQL sent to the server at all.

If, however, you are still concerned with this mechanic (for whatever reason) you can always do it ad hoc: use an IF node that branches to two different SINGLE QUERY nodes, one with the filter condition (eg. call it GetUsersFiltered) and the other without (eg. call it GetUsersAll) and then ASSIGN the query output on each side to a screen variable (eg. call it GetUsers) and use that as the source for the Table Record.

Hope this helps,


Miguel
Hi everyone,

sorry for reply now, but  wasn't possible come here early....

Thanks you all for your replies, I used the Diogo's solution.
But it's interesting to see others solutions and learn more about it.
Once again thanks for the support.

Cheers,
Bruno Santos