JOOQ中的WITH语句?

时间:2014-06-16 10:35:05

标签: java sql database orm jooq

我有MS-SQL和Oracle的查询,但我想转换成Jooq。我也尝试这样的事情DSL.connectByRoot(field)但我无法找到这个解决方案。主要问题是在Oracle中我们使用了子句connect by prior,但它在MS-SQL中不可用。

MS-SQL QUERY:

WITH tempTable(ppCode, pCode) AS (
  SELECT DefaultProcessDependent.PriorProcessCode,  ProcessCode 
  FROM DefaultProcessDependent
  WHERE DefaultProcessDependent.ProcessCode = ? 
  AND DefaultProcessDependent.FolderType  = ? 
  UNION ALL
  SELECT nplus1.PriorProcessCode, nplus1.ProcessCode
  FROM DefaultProcessDependent as nplus1, tempTable
  WHERE tempTable.ppCode = nplus1.ProcessCode
)
SELECT ppCode FROM tempTable

ORACLE QUERY:

Select processCode 
from DefaultProcessDependent 
start with  DefaultProcessDependent.ProcessCode = ? 
connect by prior processCode = priorProcessCode

任何人都应该帮助我...................

由于

1 个答案:

答案 0 :(得分:1)

Common table expressions will be supported with jOOQ 3.4。对于其他数据库,jOOQ也将emulate CONNECT BY,但在jOOQ 3.4中尚未提供。