Restrict column entry to integers
Date: Tue, 11 Jan 1994 17:32:36 GMT
Message-ID: <CJH7EC.I7L_at_empros.com>
I have a small database that will be accessed by SQL*Loader, SQL*Plus
and FORMS (probably v3). There are several columns that MUST contain
integers. I do not want to have ORACLE round a number with a scale of
zero for me. I'd like to raise an exception whenever a user tries to
use a decimal point. I can do the restriction using FORMS. Can I do it
using CONSTRAINTS?
The only methods I've thought of are
1) a trigger to convert a character column into a number
Pro: **Does what I want (raise an exception when necessary)
**Can catch ALL entries of non-integer values (even with a
single trailing decimal point)
Con: **demands extra storage space
**possible confusion among users about which column name to use
in SELECT... statements
**more coding than I'd like to maintain (I have several dozen
columns which need the integer restriction)
2) change the scale on the 'integer' columns to be non-zero and then create a constraint that checks (column=TRUNC(column)) or (column=ROUND(column))
Pro: **Does most of what I want (doesn't catch 1.0000 as not an
integer)
**allows naming the constraints to help identify the exception
Con: **AdHoc sqlplus querys show the 'integers' with non-zero scale confusing the users who 'know' which columns are 'integer' values.
**Depending on the scale chosen, may still not trap all
instances. If ORACLE still rounds, it may round to an integer depending on the input values.
I'd appreciate any help possible. I've already talked to ORACLE about this with less than stupendous success :-)
I'll post the best method suggested when I'm less than giraffe deep in work that was scheduled to be done (long ago and far away...)
Thanks in advance.......
D.J.Bowen | dbowen_at_empros.com Empros Power Systems Control | Siemens Energy and Automation, Inc. 2300 Berkshire Lane North | Voice (612) 553-4530 Plymouth, MN 55441-3694 | Fax (612) 553-4799Received on Tue Jan 11 1994 - 18:32:36 CET