我在将我的 informix db 转换为 mysql 时遇到问题。我完成了大部分工作,但有些功能不起作用。
DELIMITER //
CREATE PROCEDURE mw_getsvid(mwid INT) RETURNS INT
BEGIN
DECLARE svId INT;
SELECT sv.ID INTO svId
FROM messwert AS mw, messpunkt AS mp, mpzuordnung AS mpz, summvorschrift AS sv
LEFT JOIN messpunkt mp ON mw.messpunktid = mp.id
LEFT JOIN mpzuordnung mpz ON mp.id = mpz.messpunktid
LEFT JOIN summvorschrift sv ON mpz.summvorschriftid = sv.id
LEFT JOIN messwert mw ON mpz.zeitraum_von <= mw.datendatum
LEFT JOIN messwert mw ON mpz.zeitraum_bis > mw.datendatum;
UNION ALL
SELECT sv.ID INTO svId
FROM messwert AS mw, messpunkt AS mp, mpzuordnung AS mpz, summvorschrift AS sv
RIGHT JOIN messpunkt mp ON mw.messpunktid = mp.id
RIGHT JOIN mpzuordnung mpz ON mp.id = mpz.messpunktid
RIGHT JOIN summvorschrift sv ON mpz.summvorschriftid = sv.id
RIGHT JOIN messwert mw ON mpz.zeitraum_von <= mw.datendatum
RIGHT JOIN messwert mw ON mpz.zeitraum_bis > mw.datendatum;
RETURN svId;
END //;
DELIMITER ;
这显示:错误 1066 (42000):不是唯一的表/别名:'mp'
顺便说一句,这是旧的
CREATE PROCEDURE "informix".mw_getsvid(mwid INT)
RETURNING INT;
DEFINE svId INT;
SELECT sv.ID INTO svId
FROM MessWert mw, MessPunkt mp,
OUTER (MPZuordnung mpz, SummVorschrift sv)
WHERE mw.id = mwid
AND mw.messpunktid = mp.id
AND mp.id = mpz.messpunktid
AND mpz.summvorschriftid = sv.id
AND mpz.zeitraum_von <= mw.datendatum
AND mpz.zeitraum_bis > mw.datendatum;
RETURN svId;
END PROCEDURE;
如果你对此有一个好的想法会很棒:)