Urgent help

atuldalvi

Member
I having data like

S1S2
S1S3
.
.
.
.
S9S9
S10S10

Now there is screen where user is entering a range for data like

start = S1S1
End = S9S9

then it is working fine. It is showing all data between this range.

But if user enter range like
start = s1s1
end = s10s10

then progress failing this data range as s10s10 is less than s1s1.

How can i handle this situation.

Please help
.
 
You are going to have to parse the field into separate parts to get the sort you want.
 
???? You managed and, if you poke around, you will see this is far from my first. What is your point?
 
This is probably homework or a test question ("why are composite fields evil?") but it is an important concept so I'll take the bait.

If you can change the way these values are created that would be the first thing to do.

"S1S1" appears to be a 4 part field where "S" means something, "1" means something (and you seem to want to treat it numerically) and then the 2nd set of "S" and "1" is either redundant (it is in all of your examples) or it has still more meaning.

So create 2 (or 4) fields that represent whatever these sub-fields really are. You will then be able to very easily write a query that does exactly what you need it to do. I.e.

Code:
for each tableName where field1 = "S" and ( field2 >= 1 and field2 <= 10 ):
  /* do something */
end.

Notice how "field2" is numeric? If you want the subfield to sort numerically then you need to treat it like a number not a character (sub-)string.

If you cannot create distinct fields then

1) You are in for a life of pain and suffering. Start looking for a new job because this one will be hell on earth.

2) Maybe you can modify the data that is already in the fields while you're hunting for a new job. Parse the data and zero pad the numeric portion so that "S1S1" becomes "S01S01". Of course this will fail as soon as "S100S100" comes along so pick your length carefully. And it may have side-effects in other parts of the software. But any software that uses composite keys is buggy as all hell anyway so nobody is likely to notice.
 
Back
Top