我需要将以下触发器从oracle语法转换为Mysql语法...
以下示例我收到错误
错误代码:1327。未声明的变量:new
DELIMITER $$
CREATE TRIGGER PRE_INS_LN_CLIENTS
BEFORE INSERT
ON LN_CLIENTS
FOR EACH ROW
BEGIN
SELECT LN_CLIENTS_REC_ID_SEQ.NEXTVAL INTO new.REC_ID FROM DUAL
new.SYNC_FLAG := 'I';
END $$
DELIMITER ;
答案 0 :(得分:1)
MySQL不使用冒号,还有一些其他的小变化。我认为这会奏效:
DELIMITER $$
CREATE OR REPLACE TRIGGER PRE_DEL_LN_CLIENTS
BEFORE DELETE ON LN_CLIENTS
FOR EACH ROW
BEGIN
INSERT INTO LN_CLIENTS_DELETED (REC_ID, LOAN_NUMBER, CLIENT_SEQ_NUM, FIRST_NAME, FATHER_NAME, FAMILY_NAME, MOTHER_NAME, NATIONALITY, SEX, BIRTH_PLACE_CODE, BIRTH_PLACE_TEXT, BIRTH_DATE, REG_PLACE_CODE, REG_PLACE_TEXT, REG_NUM, ADDRESS_CODE, ADDRESS_TEXT, PHONE, EDUCATION_LEVEL_CODE, PROFESSION_CODE, PROFESSION_TEXT, MONTHLY_INCOME, WORK_PLACE, WORK_ADDRESS_TEXT, ID_DOC_TYPE, ID_DOC_NUM1, ID_DOC_NUM2, ID_DOC_DATE, NOTES, OFFICE, CREATED_BY, CREATED_ON, UPDATED_BY, UPDATED_ON, SYNC_FLAG)
VALUES(OLD.REC_ID, OLD.LOAN_NUMBER, OLD.CLIENT_SEQ_NUM, OLD.FIRST_NAME, OLD.FATHER_NAME, OLD.FAMILY_NAME, OLD.MOTHER_NAME, OLD.NATIONALITY, OLD.SEX, OLD.BIRTH_PLACE_CODE, OLD.BIRTH_PLACE_TEXT, OLD.BIRTH_DATE, OLD.REG_PLACE_CODE, OLD.REG_PLACE_TEXT, OLD.REG_NUM, OLD.ADDRESS_CODE, OLD.ADDRESS_TEXT, OLD.PHONE, OLD.EDUCATION_LEVEL_CODE, OLD.PROFESSION_CODE, OLD.PROFESSION_TEXT, OLD.MONTHLY_INCOME, OLD.WORK_PLACE, OLD.WORK_ADDRESS_TEXT, OLD.ID_DOC_TYPE, OLD.ID_DOC_NUM1, OLD.ID_DOC_NUM2, OLD.ID_DOC_DATE, OLD.NOTES, OLD.OFFICE, OLD.CREATED_BY, OLD.CREATED_ON, OLD.UPDATED_BY, OLD.UPDATED_ON, 'I');
END$$
DELIMITER ;