因为唯一性约束不能插入的出错代码(err.number)? 或者怎么知道出错是因为唯一性约束而不能插入。
---------------------------------------------------------------
你可以在插入之间检查一下:
set @count = 0
select count(id) into @count where id = @id
if @count = 0
insert into tablename ......
---------------------------------------------------------------
学习...
---------------------------------------------------------------
if exists(select * from 表 where 列=@条件)
select '有重复的' as message
else
insert ......