在我们的软件中,我们使用 Postgresql 作为具有 JDBC3 驱动程序类型的数据库。我们的 JDBC 语句使用包含“Case statement”的 SQL。
如果我们切换到另一个驱动程序或数据库,此代码是否有效:
例子:
SELECT r.routineid,
r.routinetypeid,
CASE WHEN (pc.version=20 and pc.parentid>0)
THEN CASE WHEN (r.processed='t')
THEN pc.processed ELSE r.processed
END
ELSE r.processed
END AS processed,
CASE WHEN (r.version=2 and r.parentid>0)
THEN (SELECT m_req
FROM routine
WHERE routineid=r.parentid
)
ELSE r.m_req
END AS m_req,
r.version
FROM (SELECT *
FROM routine
WHERE routinetypeid in (11,12)
AND (fbroutineid='130' OR fbroutineid='806')
) AS r
LEFT JOIN
routine pc
ON r.routineid=pc.parentid
ORDER BY r.routinetypeid;