Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the min and max value of a db field

Status
Not open for further replies.

Karen99

Programmer
Aug 5, 2003
113
0
0
ZA
TABLE1.FieldDefs.Items[7].Required tells you if a field is mandatory. In the same way I would like to know what a db (database) field max value is.

There are max and min values on persistent fields. But these does not seem to be populated by the db. What are they there for then, if they don't pick up the underlying db structure. Or do I miss something ?

Please help !!!!
 
If you need the minimum and maximum field in a database you need to write a query. If you want to apply a range of possible value, you need to define it in the Database itself, with constraints etc. (or write your own procedure in delphi for it).
The latter I personally find very ineficient, because if the database is opened by some other SQL tool, the entrance of garbage can't be avoided.

Steven van Els
SAvanEls@cq-link.sr
 
How do I write a query to get the min and max values of a field ? What is the sql code ?
 
SELECT
MAX(Field1) AS MaxVal,
MIN(Field1) AS MinVal
FROM
Table1

Simon
 
Simon, that just tells you what the min/max values used are, not the constraints. The SQL spec offers a set of system views that give you this stuff, and it should also be in the docs for your database (which are free, unlike the SQL spec). But I don't recall what they are, you'd need to look them up. Something like SYSTEM.CONSTRAINTS ;-)
 
With the sql explorer the constraints can be made visible doesn't matter the Database. SYSTEM.CONSTRAINTS is used in Interbase I think.

Regards

Steven van Els
SAvanEls@cq-link.sr
 
Do your guys know how to get this in Paradox? I know how to get it in Oracle, using dictionary views and in Sql Server. But I am not sure in Paradox? Does Paradox have something like that?

Regards
Karen
 
Hi again Karen99,

Try looking at the DBI functions in the BDE unit.

Cheers,

Andrew
 
I did look at dbi functions. The only thing I got was DbiGetFieldTypeDesc. But this only returns true or false values. Thus it only states if a field have a max or min
constraint. But it does not specify what that value is. Am I missing something ???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top