I have a table Table1 with three fields:
_PK, _Unique and _Description
The field _PK is primary key, and the field _Unique is constraint to be unique.
The _PK is generated with a sequence. In SQL Server the procedure is something like that (using a custom error)
create procedure Insert_Table1 (v_Unique ..., v_Description ...)
as
if exists (select * from Table1 where _Unique = v_Unique)
raiserror (@Custom_error, 16, 1)
else
insert into TAble1 (_UNique, _Description)
select v_Unique, v__Description
Can you tell me please how can I translate this procedure in a db2 sql procedure? Can I define a custom error?
Thanks.