Subject RE: [firebird-support] Questions about unique indexes
Author Pieter Claerhout
The trigger approach works like a charm. Thanks for the ideas...

pieter

_____

From: Helen Borrie [mailto:helebor@...]
Sent: 05 March 2004 09:41
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Questions about unique indexes


At 09:19 AM 5/03/2004 +0100, you wrote:
>Hi,
>
>imagine you have the following table:
>
>CREATE TABLE SUBSCRIPTION (
> SUBPK integer not null primary key,
> SUBURL varchar(1024) not null
>);
>
>I want to make the SUBURL a unique one, but since it's a varchar(1024),
this
>doesn't work as the column length is too long.
>
>Is there anything else I can do from the database side to ensure this field
>stays unique? Can I accomplish something with triggers?

create exception suburl_not_unique 'SubURL already exists';
commit;

create trigger bi_subscription for subscription
active before insert position 0
as
begin
...
if (exists (
select suburl from subscription
where suburl = new.suburl))
then
exception suburl_not_unique;
end





_____

Yahoo! Groups Links


* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
<http://groups.yahoo.com/group/firebird-support/>


* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>


* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .




[Non-text portions of this message have been removed]