达梦数据库建立了如下触发器
CREATE
TRIGGER HLHTMD_QY_ORG BEFORE UPDATE
OF STATE ON
IPSBTQY FOR EACH ROW
WHEN(NEW.STATE = '2')
BEGIN
IF EXISTS (
SELECT *
FROM
MD_QY_ORG
WHERE
CODE = NEW.CODE)
BEGIN --------报错位置
UPDATE
MD_QY_ORG
SET
NAME = NEW.NAME,
UNITCODE = NEW.UNITCODE,
SHORTNAME = NEW.SHORTNAME,
STOPFLAG = NEW.STOPFLAG,
PARENTCODE = NEW.PARENTCODE,
HRID = NEW.HRID,
COMPANYTYPE = NEW.COMPANYTYPE,
LEGALPERSON = NEW.LEGALPERSON,
REGISTERCAPITAL = NEW.REGISTERCAPITAL,
SETUPDATE = NEW.SETUPDATE,
BUSINESSTIMEFROM = NEW.BUSINESSTIMEFROM,
BUSINESSTIMETO = NEW.BUSINESSTIMETO,
CONTINENT = NEW.CONTINENT,
CONTRY = NEW.CONTRY,
CITYCODE = NEW.CITYCODE,
ADDRESS = NEW.ADDRESS,
SCBZ = '0'
WHERE
CODE = NEW.CODE
END
ELSE
BEGIN
INSERT
INTO
MD_QY_ORG SELECT
a.ID,
a.IPSBTQY_JGDM,
a.IPSBTQY_BTGS,
'',
'',
a.IPSBTQY_C0,
'0',
e.CREDIT_CODE,
a.UNIQUE_ID,
(CASE
a.IPSBTQY_XZ
WHEN 'ET_CG' THEN '国有参股企业'
WHEN 'ET_DZ' THEN '国有独资企业'
WHEN 'ET_JQKG' THEN '国有控股企业'
WHEN 'ET_QZ' THEN '国有全资企业'
WHEN 'ET_SJKZ' THEN '国有实际控制企业'
WHEN 'ET_QT' THEN '其他'
WHEN 'ET_SY' THEN '事业单位'
END),
a.IPSBTQY_FR,
a.IPSBTQY_ZTZE,
a.IPSBTQY_DJRQ,
a.BUSINESS_TERM_START,
a.BUSINESS_TERM_END,
(CASE
a.IPSBTQY_C5
WHEN 'WC_YZ' THEN '亚洲'
WHEN 'WC_OZ' THEN '欧洲'
WHEN 'WC_FZ' THEN '非洲'
WHEN 'WC_BMZ' THEN '北美洲'
WHEN 'WC_NMZ' THEN '南美洲'
WHEN 'WC_DYZ' THEN '大洋洲'
WHEN 'WC_NJZ' THEN '南极洲'
END),
b.NAME_CHS,
c.CODE,
a.IPSBTQY_C29,
0
FROM
IPSBTQY a
LEFT JOIN BFNATIONALANDREGIONALDICT b ON
a.IPSBTQY_C6 = b.id
LEFT JOIN BFADMINDIVISION c ON
a.IPSBTQY_C7 = c.id
LEFT JOIN IPSCOMPANYDICT e ON
a.MANAGE_COMPANY = e.ID
WHERE
a.ID = old.ID;
END
END
执行时报错位置的begin附近有错误,是哪里有问题呢
标签:begin,CODE,WC,IPSBTQY,WHEN,报错,ET,NEW,达梦 From: https://blog.51cto.com/u_16473148/8979799