Oracle SQL: Understanding the behavior of SYS_GUID() when present in an inline view?

后端 未结 3 1214
失恋的感觉
失恋的感觉 2020-12-29 05:57

Here is the example SQL in question; The SQL should run on any Oracle DBMS (I\'m running 11.2.0.2.0).

Note how the UUID values are different (one has 898 the other

3条回答
  •  囚心锁ツ
    2020-12-29 06:37

    Very interesting.

    We can use the materialize hint to fix it to.

    WITH data AS (SELECT /*+materialize*/SYS_GUID () uuid FROM DUAL)
        SELECT uuid, uuid
          FROM data;
    
    1   F9440E2613761EC8E0431206460A934C    F9440E2613761EC8E0431206460A934C
    

    From my point of view, if we can change the result of a query just by adding a hint, there is an Oracle bug. Maybe we have to ask metalink to check it...

提交回复
热议问题