Home > Archive > SQL Anywhere database > August 2005 > Trigger that mimics "unique constraint" but allows duplicate NULLS









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Trigger that mimics "unique constraint" but allows duplicate NULLS
Ed Zapalac

2005-08-22, 11:23 am

I need help writing a trigger that will fire before update and before
insert. The function of the trigger is almost identical to the "unique
constraint" requirement you can place on a field, except I want to allow
duplicate nulls. I have warehouse locations that can be unused (null), but
when they are in use I don't want to allow duplication of product serial
numbers (the serial number is unique and it is not logical to have the same
piece of equipment in two places). Any assistance you can provide would be
appreciated.

Thanks,
Edward


Bruce Hay

2005-08-22, 1:23 pm

Have you tried creating a unique index on the columns, rather than defining
a uniqueness constraint or creating a trigger? The unique index will allow
nulls.

Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer

"Ed Zapalac" <e.zapalac@ssss.com> wrote in message
news:4309f395@forums
-2-dub...
> I need help writing a trigger that will fire before update and before
> insert. The function of the trigger is almost identical to the "unique
> constraint" requirement you can place on a field, except I want to allow
> duplicate nulls. I have warehouse locations that can be unused (null),

but
> when they are in use I don't want to allow duplication of product serial
> numbers (the serial number is unique and it is not logical to have the

same
> piece of equipment in two places). Any assistance you can provide would

be
> appreciated.
>
> Thanks,
> Edward
>
>



Ed Zapalac

2005-08-22, 8:23 pm

That works. Thanks Bruce.


"Bruce Hay" < h_a_y@i~a~n~y~w~h~e~
r~e.c_o_m> wrote in message
news:430a00ae$1@foru
ms-2-dub...
> Have you tried creating a unique index on the columns, rather than
> defining
> a uniqueness constraint or creating a trigger? The unique index will allow
> nulls.
>
> Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
> Developer Community at http://www.ianywhere.com/developer
>
> "Ed Zapalac" <e.zapalac@ssss.com> wrote in message
> news:4309f395@forums
-2-dub...
> but
> same
> be
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com