小编elm*_*mon的帖子

cx_Oracle忽略order by子句

我在我的项目中创建了复杂的查询构建器,并且在测试期间偶然发现了奇怪的问题:具有相同计划的相同查询在不同客户端上产生不同的结果:cx_Oracle忽略order by子句,而Oracle SQLDeveloper Studio正确处理查询,但在这两种情况下在两个计划中按目前排序.

有问题的查询是:

select *
from
(
    select 
        a.*,
        ROWNUM tmp__rnum
    from
    (
        select base.* 
        from
        (
            select id
            from
            (
                (
                    select 
                    profile_id as id,
                    surname as sort__col 
                    from names
                )
                /* here usually are several other subqueries chained by unions */
            )
            group by id
            order by min(sort__col) asc
        ) tmp
        left join (profiles) base
        on tmp.id = base.id
        where exists 
        (
            select t.object_id 
            from object_rights t 
            where
                    t.object_id = base.id 
                and t.subject_id = :a__subject_id 
                and …
Run Code Online (Sandbox Code Playgroud)

python sql oracle cx-oracle

2
推荐指数
1
解决办法
169
查看次数

标签 统计

cx-oracle ×1

oracle ×1

python ×1

sql ×1