Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 10 of 15 total |
Runtime dependent number of float value WHERE conditions |
Mon, Jun 4 2012 11:02 AM | Permanent Link |
Janusz Cyran | Hi,
How can I build an UPDATE (or SELECT) with a variable (runtime dependent) number of float number WHERE conditions? Regards, JC |
Mon, Jun 4 2012 11:43 AM | Permanent Link |
Uli Becker | Janusz,
> How can I build an UPDATE (or SELECT) with a variable (runtime dependent) number of float number WHERE conditions? Sorry, I don't understand exactly what you mean? Can you make it clear? Uli |
Mon, Jun 4 2012 2:40 PM | Permanent Link |
Janusz Cyran | Uli Becker wrote:
Janusz, > How can I build an UPDATE (or SELECT) with a variable (runtime dependent) number of float number WHERE conditions? Sorry, I don't understand exactly what you mean? Can you make it clear? Uli |
Mon, Jun 4 2012 3:16 PM | Permanent Link |
Janusz Cyran | Uli,
I need to construct SELECT or UPDATE with WHERE clause and the condition like that: SELECT ... WHERE Field1 = float1 AND Field2 = float2... AND FieldN = floatN Field names and corresponding values are taken from tables which are dynamically created during program execution. I can do it with character fields putting the string values from the table in a loop that way: ... q.SQL.Add(FieldNamesTable[i] + ' = ' + QuotedStr(StringValuesTable[i])) ... but I cannot figure out how to do it with decimal fields values. JC Uli Becker wrote: Janusz, > How can I build an UPDATE (or SELECT) with a variable (runtime dependent) number of float number WHERE conditions? Sorry, I don't understand exactly what you mean? Can you make it clear? Uli |
Mon, Jun 4 2012 4:01 PM | Permanent Link |
Uli Becker | Janusz,
> I can do it with character fields putting the string values from the table in a loop that way: > .. > q.SQL.Add(FieldNamesTable[i] + ' = ' + QuotedStr(StringValuesTable[i])) > .. > but I cannot figure out how to do it with decimal fields values. Sorry, I still don't understand exactly. Do you have 2 tables, one with the Fieldnames and one with the matching values as strings? In this case you can use "cast", e.g. SQL.Add(FieldNamesTable[i] + ' = ' + CAST(StringValuesTable[i] as FLOAT) Uli |
Tue, Jun 5 2012 2:53 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Janusz
I think I understand what you're asking but I'm not certain. Use code like q.SQL.Add(FieldNamesTable[i] + ' = ' + FlotToStr(FloatValuesTable[i])) Roy Lambert [Team Elevate] |
Tue, Jun 5 2012 2:57 AM | Permanent Link |
Uli Becker | Forget about my posting - complete nonsense. Sorry.
|
Tue, Jun 5 2012 5:03 AM | Permanent Link |
Janusz Cyran | Roy,
Sorry for being unclear. I had tried exactly the same code as you proposes but got errors. Well, just because FloatToStr returns float numbers in local format with comma decimal point (',') instead of dot ('.'). Now I replace comma with dot in returned string and it works fine but I don't feel it is a good solution. Regards, JC Roy Lambert wrote: Janusz I think I understand what you're asking but I'm not certain. Use code like q.SQL.Add(FieldNamesTable[i] + ' = ' + FlotToStr(FloatValuesTable[i])) Roy Lambert [Team Elevate] |
Wed, Jun 6 2012 2:19 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Janusz
Even if I was right you may still have problems. Float equality tests are bad news. You would need to guarantee whatever produced the two floats was working exactly the same, and storing them the same and that FloatToStr was producing what you expected. If you're only interested in a match to a specific number of decimal places then you'd be better off using CAST(floatfield AS DECIMAL(x,y)) and using the Delphi Format function to format the float from the other table or CASTing that value as well. If you have problems let us know a bit more about what you're actually trying to achieve and we should be able to help. Roy Lambert [Team Elevate] |
Wed, Jun 6 2012 4:48 AM | Permanent Link |
John Hay | Janusz
> Sorry for being unclear. I had tried exactly the same code as you proposes but got errors. Well, just because FloatToStr returns float numbers in local format with comma decimal point (',') instead of dot ('.'). Now I replace comma with dot in returned string and it works fine but I don't feel it is a good solution. > I would use formatfloat instead of floattostr. This allows you to pass your own TFormatSettings with the decimal separator set to a point. There is a discussion on this at http://stackoverflow.com/questions/9814073/is-it-ok-to-use-decimalseparator-to-force-floattostr-strtofloat-functions-to-use John |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Sunday, May 5, 2024 at 10:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |