[7.0] Simple Query Condition

[7.0] Simple Query Condition



Can we build an if condition inside a Simple Query.

My problem is this one, in a ComboBox I want to list only the values that are available. What I want to do, is create a exception, if the Table.Id = NullIdentifier() is true the query runs the condition, if the if condition returns false, we get no conditions. When I am creating a new shipment, I got no problems and the filter runs well, but, if I am editing a existing one the Trailer Plate and Container Plate dont get the values.

PS: the Trailers/Containers are available when the Trailers_Unloading_Date are lower then the Current Date.

Hi Henrique,

May I ask why on earth you are working with such an old version of the Platform?

That said, it's not completely clear to me based on your description of the problem what exactly you are trying to achieve. However, since you can use AND and OR in conditions, you could do something like "Table.Id <> NullIdentifier or [whatever condition]"?

It didnt solve the problem. Maybe with a advanced SQL Query?

Well, as I said, I don't understand your problem. Could you please explain again what exactly you want to achieve?

I want to do something like this.

When the Id is null we use the condition, when is not null, I get the value from the Id.

SELECT {Italia_Container}.* ,
CASE @ContainerId
    WHEN @ContainerId IS NULL THEN {Italia_Container}.[Unloading_Date] < GETDATE()
    ELSE {Italia_Container}.[Id] = @ContainerId 
FROM {Italia_Container}


SELECT {Italia_Container}.*
FROM {Italia_Container}
WHERE {Italia_Container}.[Id] = @ContentorID  

union all

SELECT {Italia_Container}.* 
FROM {Italia_Container}
WHERE {Italia_Container}.[Unloading_Date] < GetDate()

Ah, right, like that. A simple query won't help you there (iirc, they don't even have a choice of output columns). If you ever upgrade to a more modern version of OutSystems, you can do that with calculated Aggregate columns, but since you're on version 7, you'll have to write an Advanced Query.