SQLJ中的递归查询

时间:2013-05-05 18:10:40

标签: java sql oracle sqlj

我想在 SQLJ (是的......)中提供一些帮助。我在谷歌上搜索如何在这个内联java SQL中重现递归SQL查询。参考文献也很受欢迎,因为它也很难找到......

我的SQL查询:

WITH attachedemails(id, subject, filename) 
     AS ( 
        -- Ancora (224)   
        SELECT email 
        FROM   (SELECT addressee.email AS email 
                FROM   addressee 
                WHERE  addressee.email->from 
                    IN (SELECT address 
                        FROM   use 
                        WHERE use.user->nickname = User.nickname <arg>) 
                UNION 
                SELECT addressee.email 
                FROM   addressee 
                WHERE  addressee.to 
                    IN (SELECT address 
                    FROM   use 
                    WHERE use.user->nickname = = User.nickname <arg>))) 
               AS t 
        WHERE  email->DATE >= FROM <arg> AND  email->DATE <= TO <arg> )           

         UNION ALL 

         SELECT m.id 
         FROM   email AS m, 
                attachedemails AS c 
         WHERE  m.contained_in = c.id 
                AND m.DATE >= FROM <arg> AND  email->DATE <= TO <arg> )) 

基本上,我收到一些给定用户的电子邮件和其他电子邮件附带的电子邮件。我标记了我的Java参数,我应该用它来过滤结果。

我知道为了使用SQLJ返回多行,我们需要一个迭代器,并且我可以在子查询中使用它们的不同级别,但递归非常难以模拟。也许还有其他一些专门针对SQLJ的构造,我不知道。我希望有人可以帮忙!

0 个答案:

没有答案