Subject | Re: [firebird-support] Questions about unique indexes |
---|---|
Author | Helen Borrie |
Post date | 2004-03-05T08:40:52Z |
At 09:19 AM 5/03/2004 +0100, you wrote:
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
>Hi,create exception suburl_not_unique 'SubURL already exists';
>
>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?
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