- create TRIGGER VerifyPhone
- on T_client
- instead of insert,update
- as
- begin
- declare @i smallint,@b smallint,@tel varchar(20)
- set @tel=(select cli_tel from INSERTED)
-
- select @b=1
- select @i=1
- while @i<=len(@tel) and @b=1
- begin
- if (ascii(substring(@tel,@i,1))<48 or ascii(substring(@tel,@i,1))>57) and (ascii(substring(@tel,@i,1))<>46)
- select @b=0
- select @i=@i+1
- end
- if @b=0
- begin
- ROLLBACK TRANSACTION
- print 'Transaction annulée'
- print 'numéro de téléphone Invalide'
- end
- else
- begin
- if update(cli_tel)
- delete T_client where cli_id=(select cli_id from deleted)
- insert T_client select * from INSERTED
- end
- end
create TRIGGER VerifyPhone
on T_client
instead of insert,update
as
begin
declare @i smallint,@b smallint,@tel varchar(20)
set @tel=(select cli_tel from INSERTED)
select @b=1
select @i=1
while @i<=len(@tel) and @b=1
begin
if (ascii(substring(@tel,@i,1))<48 or ascii(substring(@tel,@i,1))>57) and (ascii(substring(@tel,@i,1))<>46)
select @b=0
select @i=@i+1
end
if @b=0
begin
ROLLBACK TRANSACTION
print 'Transaction annulée'
print 'numéro de téléphone Invalide'
end
else
begin
if update(cli_tel)
delete T_client where cli_id=(select cli_id from deleted)
insert T_client select * from INSERTED
end
end