Unsigned numbers
Unsigned numbers
От:
Kaloyan Iliev Iliev <news1@faith.digsys.bg>
Дата:
Hello Friends, I have the following questions. I have a lot of fields in my database that are int or float. The problem is that I need them to be only positive (unsigned) and the users try to insert sometimes negative. I know that I can make this with CHECK CONSTRAINT but for some reasons this is not a good solution for me. The reason is that when I have a check constraint on a certain field and someone try to insert negative number the error message contains the name of the constraint and the name of the table but not the name of the field. So on higher level I can't send a proper message to the user. Are there any unsigned data types like unsigned int or unsigned float. Can I make a domain or something like that (How exactly to add constraint to domain). I am using v7.3.2. Thanks!
Re: Unsigned numbers
От:
Richard Huxton <dev@archonet.com>
Дата:
On Wednesday 26 November 2003 11:10, Kaloyan Iliev Iliev wrote: > Hello Friends, > > I have the following questions. > I have a lot of fields in my database that are int or float. > The problem is that I need them to be only positive (unsigned) and the > users try to insert sometimes negative. [snip - problem is that errors give constraint name] > Are there any unsigned data types like unsigned int or unsigned float. > Can I make a domain or something like that (How exactly to add > constraint to domain). > I am using v7.3.2. Adding CHECKs to domains is new for 7.4, I believe. There aren't any built-in unsigned types, although in theory you could write your own. What I do is format my constraint names in a known way. So, a check on table foo, column bar might be called "foo_bar_positive" - then I can get the information I want from the constraint name. -- Richard Huxton Archonet Ltd