在存储过程或触发器中调用,例如:CREATE TRIGGER GOODSTYPETRIGGER2 FOR GOODSTYPE AFTER DELETE POSITION 0 AS
BEGIN
if (exists (select lcode from goodstype where lcode like old.lcode||"%"))
then exception areareturn;//这句;
ENDCREATE PROCEDURE CHECKNAME (
  LCODETABLE VARCHAR(20),
  KEYVALUE SMALLINT,
  LCODEVALUE VARCHAR(10),
  CHECKINGNAME VARCHAR(20)
)  AS                                               
declare variable tempvalue varchar(20);
declare variable templcode varchar(10);
declare variable sublcode varchar(10);
declare variable tempid smallint;
BEGIN
sublcode=substr(lcodevalue,1,getstrlength(lcodevalue)-2);
if (lcodetable="area") then
begin
FOR SELECT areaid,name,lcode from area where lcode like :sublcode||"__"  into :tempid, :tempvalue,:templcode
do
  begin
    if ((keyvalue!=tempid)and(tempvalue=checkingname)) then 
       exception invalidname;  //<-这句;
  end
end
if (lcodetable="ietype") then
begin
FOR SELECT ietypeid,name,lcode from ietype where lcode like :sublcode||"__" into :tempid,:tempvalue,:templcode
do
  begin
    if ((keyvalue!=tempid)and(tempvalue=checkingname)) then 
       exception invalidname;//<-这句;
  end
  end
end
if (lcodetable="goodstype") then
begin
FOR SELECT goodstypeid,name,lcode from goodstype where lcode like :sublcode||"__" into :tempid,:tempvalue,:templcode
do
  begin
    if ((keyvalue!=tempid)and(tempvalue=checkingname)) then 
       exception invalidname;
  end
end
END