Simple Query Max. Records

Simple Query Max. Records


I'm having a problem with a Simple Query with it's Max. Records property.

I want the Max. Records to be passed by a integer variable, let's say RecordNumber, and when I don't define its value it should return all the rows, otherwise, if the value is greater than zero it should return that exact number of rows.
The problem is when I don't define the value, so by default is zero, and the query only returns 1 row.

If anyone knows how to solve it I would apreciate.
Thanks in advance.

There is a simple way to do that...

First you can test if the RecordNumber is defined using a IF widget and test he's value.

If the RecordNumber is defined:
You can see the SQL code of the simple query and build a advanced query with them, that receives a input parameter the number of rows that you want to return.
for example:
select top @RecordNumber (...)

if the RecordNumber is not defined you can use a simple query with a huge returned rows limit.

Hope it helps,
Luis Paulo Soares
if recordnumber is defined
------- use a advanced query with top @recordnumber
------- use a simple query
Hi Luis Paulo Soares.

Thanks for your answer.
In fact that way it works just fine.

What I don't understand is why OutSystems doesn't suport the null value (in this case, of integer variable, the 0 value) in the parameter Max. Records, because it should work.

Once again thank you.
Best regards.
That field is mandatory probably because on he's backcode its using the top on the sql simple query widget. They probably missing the test to see if its value is empty and if yes it shouldnt use the top.
If not use the top.

You can always suggest that on the wishlist.

best regards,
Luis Paulo Soares