| View previous topic :: View next topic |
| Author |
Message |
amarumayo Newbie

Joined: 02 Jul 2012 Posts: 3
|
Posted: Mon Jul 02, 2012 6:46 am Post subject: Data Validation - set range |
|
|
I am trying to limit the range on a numeric import on a form. I.e. if the user enters 155 when the range is set from 50-150 it will return and error so that I can minimize data entry mistakes. I understand that this may need a SQL command. Any ideas?
Thanks |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Jul 02, 2012 8:10 am Post subject: |
|
|
On form level you can do this with a numeric control which allows you to specify an minimum and a maximum (a "formatted control" I think).
Below form level (e.g. table/query/update) you can still enter arbitrary numbers within the range of the data type.
Try this one in Tools>SQL:
ALTER TABLE "YOUR_TABLE" ADD CONSTRAINT "Range_Limit" CHECK "YOUR_FIELD" BETWEEN 50 AND 150
You can remove the constraint like this:
ALTER TABLE "YOUR_TABLE" DROP CONSTRAINT "Range_Limit"
In HSQLDB such a constraint is limited to the field values of one row. It can not do any comparison between other rows nor tables.
This is another variant comparing 2 fields:
ALTER TABLE "YOUR_TABLE" ADD CONSTRAINT "Range_Limit" CHECK "From_Time" <= "Until_Time" _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
|