Notifications
Announcements
No record found.
Hi,
I have one Table which is having two fields "From" and "To". I need to select between these fields. If i enter a new value in the table , if the entered value in the "From" overlaps between the previously entered values. It should not accept the value to be inserted.
For eg: The 1 to 1500 already inserted, if i try to enter 10 to 1000 it should not be inserted. Help me on this. TIA
Regards,
Ram
If I am not wrong you want not only "from" but "to" do must not between these fields. Maybe something like this;
Table tableInsert, tableCheck; tableInsert.From = 10; tableInsert.To = 120; select firstOnly tableCheck where(tableCheck.From >= tableInsert.From && tableCheck.To <= tableInsert.From) ||(tableCheck.From >= tableInsert.To && tableCheck.To <= tableInsert.To); if(tableCheck) { error(".."); }
What exactly is the problem?
You don't know how to validate records on save? If so, use validateWrite() method and return false if the check fails.
Or you don't know how to compare values? You have operators like >, <, >= and <=.
Or you don't know what logic you need to find conflicting records? What about something like this:
select firstOnly RecId from myTable where (myTable.From < this.From && myTable.To > this.From) || (myTable.From > this.To && myTable.To < this.To);
Hi Ergun,
I have to compare between two fields in only one table.
It's the same table. But you need two buffers - the one that you're saving and the other for finding existing records.
Dont you have two record (an old and a new).
Thanks Martin, Ergun . I have confused with the buffers sorry. It works
I have one condition which is the To value should be greater than From Value. How it should be written.
regards,
If you look at code samples above, you can see how to compare fields. What else do you need? Please elaborate.
These codes check whether the fields are in range individually. It doesn't matter which field is big. If either of them is in range, the old record will return.
If you want to add a new condition (from not greater than to), simply compare the new record.
if (tableInsert.From> tableInsert.To)
If you don't have such a request, the above codes will do the trick.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 565 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
Sohaib Cheema 250 User Group Leader