Home » SQL & PL/SQL » SQL & PL/SQL » Materialize hint giving different results (Oracle 10.2.0.3)
icon5.gif  Materialize hint giving different results [message #505396] Mon, 02 May 2011 16:02 Go to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
According to the article below, this issue doesn't happen in 10g databases

databasedoc.blogspot.com/2006_08_01_archive.html

And yet, when I try the following query in sql developer with and without materialize hint, I get different results:


(without using materialize hint)

WITH MANAGERS AS (
SELECT A.H_UNIV_ID
FROM PS_H_PD_EE_RPTS_TO A
WHERE A.H_UNIV_ID like 'E4%'
CONNECT BY PRIOR A.H_UNIV_ID=A.H_MGR1_EID START WITH A.H_UNIV_ID='E700025')
SELECT * FROM MANAGERS

....
E411245
E421903
E468761
E468784

2278 rows selected


(using materialize hint)

WITH MANAGERS AS (
SELECT /*+materialize*/ A.H_UNIV_ID
FROM PS_H_PD_EE_RPTS_TO A
WHERE A.H_UNIV_ID like 'E4%'
CONNECT BY PRIOR A.H_UNIV_ID=A.H_MGR1_EID START WITH A.H_UNIV_ID='E700025')
SELECT * FROM MANAGERS

....
E159625
E447346
E504514
E374545
Only 5000 rows currently supported in a script results
5000 rows selected

However, if I do this:

WITH MANAGERS AS (
SELECT /*+materialize*/ A.H_UNIV_ID
FROM PS_H_PD_EE_RPTS_TO A
WHERE A.H_UNIV_ID like 'E4%'
CONNECT BY PRIOR A.H_UNIV_ID=A.H_MGR1_EID START WITH A.H_UNIV_ID='E700025')
SELECT count(*) FROM MANAGERS

I get this:

COUNT(*)
----------------------
2278

1 rows selected



Re: Materialize hint giving different results [message #505398 is a reply to message #505396] Mon, 02 May 2011 17:00 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
That's interesting.
So, what can we do for you?
Re: Materialize hint giving different results [message #505400 is a reply to message #505398] Mon, 02 May 2011 17:41 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
I suppose I'm just looking to see if anyone has encountered this before in 10g or can confirm it is a bug so I can tell our dba to look for patches or work with Oracle support to resolve.
Re: Materialize hint giving different results [message #505401 is a reply to message #505400] Mon, 02 May 2011 17:46 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
We don't have your tables or data so can't do anything with posted SQL.
V10 is no longer in full support.
Can problem be reproduced using V11.2?
Re: Materialize hint giving different results [message #505402 is a reply to message #505401] Mon, 02 May 2011 17:56 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
I don't have access to 11g db right now. Perhaps someone can try it against the emp table and check if the bug still exists in 11g (or does truly exist in 10g and not a configuration issue)
Re: Materialize hint giving different results [message #505404 is a reply to message #505402] Mon, 02 May 2011 18:08 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I don't have access to 11g db right now.
then you are past due to install V11.2 on your PC.
Re: Materialize hint giving different results [message #505405 is a reply to message #505404] Mon, 02 May 2011 18:16 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
Not an option for the moment, the client I'm working for currently is still on 10g and all I can do is try and confirm it is a bug on 10g and provide workarounds if there are no patches available.
Re: Materialize hint giving different results [message #505406 is a reply to message #505405] Mon, 02 May 2011 18:23 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post FORMATTED EXPLAIN PLAN for both queries.
Re: Materialize hint giving different results [message #505407 is a reply to message #505406] Mon, 02 May 2011 18:31 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
Without materialize hint:
---------------------------------------------------------------------------------------
| Id  | Operation                   | Name               | Rows  | Bytes | Cost (%CPU)|
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                    |     8 |   112 |     2   (0)|
|   1 |  VIEW                       |                    |     8 |   112 |     2   (0)|
|   2 |   FILTER                    |                    |       |       |            |
|   3 |    CONNECT BY WITH FILTERING|                    |       |       |            |
|   4 |     INDEX RANGE SCAN        | PSAH_PD_EE_RPTS_TO |     1 |    40 |     2   (0)|
|   5 |     NESTED LOOPS            |                    |       |       |            |
|   6 |      BUFFER SORT            |                    |       |       |            |
|   7 |       CONNECT BY PUMP       |                    |       |       |            |
|   8 |      INDEX RANGE SCAN       | PS0H_PD_EE_RPTS_TO |     8 |   128 |     2   (0)|
|   9 |     INDEX FAST FULL SCAN    | PS0H_PD_EE_RPTS_TO | 81316 |  2541K|    62   (2)|
---------------------------------------------------------------------------------------

Using materialize hint:
---------------------------------------------------------------------------------------------------
| Id  | Operation                      | Name                        | Rows  | Bytes | Cost (%CPU)|
---------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |                             | 81316 |  1111K|    39   (3)|
|   1 |  TEMP TABLE TRANSFORMATION     |                             |       |       |            |
|   2 |   LOAD AS SELECT               |                             |       |       |            |
|   3 |    CONNECT BY WITH FILTERING   |                             |       |       |            |
|   4 |     TABLE ACCESS BY INDEX ROWID| PS_H_PD_EE_RPTS_TO          |       |       |            |
|   5 |      INDEX UNIQUE SCAN         | PS_H_PD_EE_RPTS_TO          |     1 |     8 |     1   (0)|
|   6 |     NESTED LOOPS               |                             |       |       |            |
|   7 |      BUFFER SORT               |                             |       |       |            |
|   8 |       CONNECT BY PUMP          |                             |       |       |            |
|   9 |      INDEX RANGE SCAN          | PS0H_PD_EE_RPTS_TO          |     8 |   128 |     2   (0)|
|  10 |     TABLE ACCESS FULL          | PS_H_PD_EE_RPTS_TO          |     8 |   128 |     2   (0)|
|  11 |   VIEW                         |                             | 81316 |  1111K|    37   (3)|
|  12 |    TABLE ACCESS FULL           | SYS_TEMP_0FD9D6624_CF7C4606 | 81316 |   635K|    37   (3)|
---------------------------------------------------------------------------------------------------
Re: Materialize hint giving different results [message #505409 is a reply to message #505407] Mon, 02 May 2011 18:45 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
does doing below change anything?

SELECT /*+materialize*/ A.H_UNIV_ID
not as above but as below
SELECT /*+ materialize */ A.H_UNIV_ID
-- extra spaces within the " hint "
Re: Materialize hint giving different results [message #505410 is a reply to message #505409] Mon, 02 May 2011 19:01 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
adding the spaces did nothing - same (incorrect) results
Re: Materialize hint giving different results [message #505411 is a reply to message #505410] Mon, 02 May 2011 19:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
it appears to be a bug to me.
Re: Materialize hint giving different results [message #505413 is a reply to message #505411] Mon, 02 May 2011 23:28 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
...but unfortunately "materialize" is a not documented and so not supported hint.
Ayway, there are many bugs about CONNECT BY in 10g (also in 9i).

First be sure your statistics are up to date.
Then rebuild the indexes.

If there is no change then you can try the statement first with "_optimizer_connect_by_combine_sw" = FALSE.
If it does not work, reset it to TRUE and try with "_optimizer_connect_by_cost_based" = FALSE.
If is still nork, reset it to TRUE and try with "_old_connect_by_enabled" = TRUE.

Regards
Michel
Re: Materialize hint giving different results [message #505415 is a reply to message #505402] Tue, 03 May 2011 00:07 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
jbarril wrote on Mon, 02 May 2011 15:56

I don't have access to 11g db right now. Perhaps someone can try it against the emp table and check if the bug still exists in 11g (or does truly exist in 10g and not a configuration issue)


Using the materialize hint in 11g on a small data set, such as the emp table produces a different execution plan with temp table transformation, but does not produce incorrect results. I did not test on a larger dataset and don't know if that would matter.

SCOTT@orcl_11gR2> SELECT * FROM v$version
  2  /

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE	11.2.0.1.0	Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

5 rows selected.

SCOTT@orcl_11gR2> CREATE TABLE test_tab AS
  2  SELECT empno, mgr
  3  FROM   emp
  4  /

Table created.

SCOTT@orcl_11gR2> CREATE INDEX test_tab_empno_mgr_idx ON test_tab (empno, mgr)
  2  /

Index created.

SCOTT@orcl_11gR2> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'TEST_TAB')

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> SET AUTOTRACE ON EXPLAIN
SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  a.empno
  4  	  FROM	  test_tab a
  5  	  CONNECT BY PRIOR a.empno = a.mgr
  6  	  START   WITH a.empno = 7839)
  7  SELECT * FROM managers
  8  /

     EMPNO
----------
      7839
      7566
      7788
      7876
      7902
      7369
      7698
      7499
      7521
      7654
      7844
      7900
      7782
      7934

14 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 923281667

-------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                         |                        |    14 |   182 |     2  (50)| 00:00:01 |
|   1 |  VIEW                                    |                        |    14 |   182 |     2  (50)| 00:00:01 |
|*  2 |   CONNECT BY NO FILTERING WITH START-WITH|                        |       |       |            |          |
|   3 |    INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX |    14 |   112 |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  /*+materialize*/ a.empno
  4  	  FROM	  test_tab a
  5  	  CONNECT BY PRIOR a.empno = a.mgr
  6  	  START   WITH a.empno = 7839)
  7  SELECT * FROM managers
  8  /

     EMPNO
----------
      7839
      7566
      7788
      7876
      7902
      7369
      7698
      7499
      7521
      7654
      7844
      7900
      7782
      7934

14 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1775495776

------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                 | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                          |                            |     3 |    39 |     4  (25)| 00:00:01 |
|   1 |  TEMP TABLE TRANSFORMATION                |                            |       |       |            |          |
|   2 |   LOAD AS SELECT                          | SYS_TEMP_0FD9D6626_3DDE2D0 |       |       |            |          |
|*  3 |    CONNECT BY NO FILTERING WITH START-WITH|                            |       |       |            |          |
|   4 |     INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX     |    14 |   112 |     1   (0)| 00:00:01 |
|   5 |   VIEW                                    |                            |     3 |    39 |     2   (0)| 00:00:01 |
|   6 |    TABLE ACCESS FULL                      | SYS_TEMP_0FD9D6626_3DDE2D0 |     3 |    12 |     2   (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  /*+materialize*/ a.empno
  4  	  FROM	  test_tab a
  5  	  CONNECT BY PRIOR a.empno = a.mgr
  6  	  START   WITH a.empno = 7839)
  7  SELECT COUNT (*) FROM managers
  8  /

  COUNT(*)
----------
        14

1 row selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1234134307

------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                 | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                          |                            |     1 |       |     4  (25)| 00:00:01 |
|   1 |  TEMP TABLE TRANSFORMATION                |                            |       |       |            |          |
|   2 |   LOAD AS SELECT                          | SYS_TEMP_0FD9D6628_3DDE2D0 |       |       |            |          |
|*  3 |    CONNECT BY NO FILTERING WITH START-WITH|                            |       |       |            |          |
|   4 |     INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX     |    14 |   112 |     1   (0)| 00:00:01 |
|   5 |   SORT AGGREGATE                          |                            |     1 |       |            |          |
|   6 |    VIEW                                   |                            |     3 |       |     2   (0)| 00:00:01 |
|   7 |     TABLE ACCESS FULL                     | SYS_TEMP_0FD9D6628_3DDE2D0 |     3 |    12 |     2   (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2>

Re: Materialize hint giving different results [message #505523 is a reply to message #505415] Tue, 03 May 2011 08:31 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
Thanks Barbara, however can you try one more thing - add another criteria on the where clause to filter the results (say where EMPNO > 7800). According to the article, when the temp table transformation happens, some of the criteria get lost, which is what was happening to me also (I had WHERE H_UNIV_ID LIKE 'E4%'). Of course when I remove it I get the same results with or without the hint.
Re: Materialize hint giving different results [message #505550 is a reply to message #505523] Tue, 03 May 2011 13:07 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
jbarril wrote on Tue, 03 May 2011 06:31

Thanks Barbara, however can you try one more thing - add another criteria on the where clause to filter the results (say where EMPNO > 7800). According to the article, when the temp table transformation happens, some of the criteria get lost, which is what was happening to me also (I had WHERE H_UNIV_ID LIKE 'E4%'). Of course when I remove it I get the same results with or without the hint.


SCOTT@orcl_11gR2> SELECT * FROM v$version
  2  /

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE	11.2.0.1.0	Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

5 rows selected.

SCOTT@orcl_11gR2> CREATE TABLE test_tab AS
  2  SELECT empno, mgr
  3  FROM   emp
  4  /

Table created.

SCOTT@orcl_11gR2> CREATE INDEX test_tab_empno_mgr_idx ON test_tab (empno, mgr)
  2  /

Index created.

SCOTT@orcl_11gR2> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'TEST_TAB')

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> SET AUTOTRACE ON EXPLAIN
SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  a.empno
  4  	  FROM	  test_tab a
  5  	  WHERE   empno > 7800
  6  	  CONNECT BY PRIOR a.empno = a.mgr
  7  	  START   WITH a.empno = 7839)
  8  SELECT * FROM managers
  9  /

     EMPNO
----------
      7839
      7876
      7902
      7844
      7900
      7934

6 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 735014586

--------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                 | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                          |                        |    14 |   182 |     2  (50)| 00:00:01 |
|   1 |  VIEW                                     |                        |    14 |   182 |     2  (50)| 00:00:01 |
|*  2 |   FILTER                                  |                        |       |       |            |          |
|*  3 |    CONNECT BY NO FILTERING WITH START-WITH|                        |       |       |            |          |
|   4 |     INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX |    14 |   112 |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("A"."EMPNO">7800)
   3 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  /*+materialize*/ a.empno
  4  	  FROM	  test_tab a
  5  	  WHERE   empno > 7800
  6  	  CONNECT BY PRIOR a.empno = a.mgr
  7  	  START   WITH a.empno = 7839)
  8  SELECT * FROM managers
  9  /

     EMPNO
----------
      7839
      7876
      7902
      7844
      7900
      7934

6 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1653721301

-------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                  | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                           |                            |     3 |    39 |     4  (25)| 00:00:01 |
|   1 |  TEMP TABLE TRANSFORMATION                 |                            |       |       |            |          |
|   2 |   LOAD AS SELECT                           | SYS_TEMP_0FD9D6606_3DFAEF7 |       |       |            |          |
|*  3 |    FILTER                                  |                            |       |       |            |          |
|*  4 |     CONNECT BY NO FILTERING WITH START-WITH|                            |       |       |            |          |
|   5 |      INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX     |    14 |   112 |     1   (0)| 00:00:01 |
|   6 |   VIEW                                     |                            |     3 |    39 |     2   (0)| 00:00:01 |
|   7 |    TABLE ACCESS FULL                       | SYS_TEMP_0FD9D6606_3DFAEF7 |     3 |    12 |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter("A"."EMPNO">7800)
   4 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2> WITH
  2    managers AS
  3  	 (SELECT  /*+materialize*/ a.empno
  4  	  FROM	  test_tab a
  5  	  WHERE   empno > 7800
  6  	  CONNECT BY PRIOR a.empno = a.mgr
  7  	  START   WITH a.empno = 7839)
  8  SELECT COUNT (*) FROM managers
  9  /

  COUNT(*)
----------
         6

1 row selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1884793425

-------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                  | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                           |                            |     1 |       |     4  (25)| 00:00:01 |
|   1 |  TEMP TABLE TRANSFORMATION                 |                            |       |       |            |          |
|   2 |   LOAD AS SELECT                           | SYS_TEMP_0FD9D6608_3DFAEF7 |       |       |            |          |
|*  3 |    FILTER                                  |                            |       |       |            |          |
|*  4 |     CONNECT BY NO FILTERING WITH START-WITH|                            |       |       |            |          |
|   5 |      INDEX FULL SCAN                       | TEST_TAB_EMPNO_MGR_IDX     |    14 |   112 |     1   (0)| 00:00:01 |
|   6 |   SORT AGGREGATE                           |                            |     1 |       |            |          |
|   7 |    VIEW                                    |                            |     3 |       |     2   (0)| 00:00:01 |
|   8 |     TABLE ACCESS FULL                      | SYS_TEMP_0FD9D6608_3DFAEF7 |     3 |    12 |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter("A"."EMPNO">7800)
   4 - access("A"."MGR"=PRIOR "A"."EMPNO")
       filter("A"."EMPNO"=7839)

SCOTT@orcl_11gR2> 

Re: Materialize hint giving different results [message #505551 is a reply to message #505550] Tue, 03 May 2011 13:14 Go to previous messageGo to next message
jbarril
Messages: 10
Registered: May 2011
Junior Member
Thanks very much Barbara. Looks like it's fixed on 11.2, would be great if someone can try the same on a 10g db
Re: Materialize hint giving different results [message #505552 is a reply to message #505551] Tue, 03 May 2011 13:29 Go to previous message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
Here is the test script, in case anyone else wants to run it on their system:

SET LINESIZE 130
SELECT * FROM v$version
/
CREATE TABLE test_tab AS
SELECT empno, mgr
FROM   emp
/
CREATE INDEX test_tab_empno_mgr_idx ON test_tab (empno, mgr)
/
EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'TEST_TAB')
SET AUTOTRACE ON EXPLAIN
WITH 
  managers AS 
    (SELECT  a.empno
     FROM    test_tab a
     WHERE   empno > 7800
     CONNECT BY PRIOR a.empno = a.mgr 
     START   WITH a.empno = 7839)
SELECT * FROM managers
/
WITH 
  managers AS 
    (SELECT  /*+materialize*/ a.empno
     FROM    test_tab a
     WHERE   empno > 7800
     CONNECT BY PRIOR a.empno = a.mgr 
     START   WITH a.empno = 7839)
SELECT * FROM managers
/
WITH 
  managers AS 
    (SELECT  /*+materialize*/ a.empno
     FROM    test_tab a
     WHERE   empno > 7800
     CONNECT BY PRIOR a.empno = a.mgr 
     START   WITH a.empno = 7839)
SELECT COUNT (*) FROM managers
/
SET AUTOTRACE OFF
drop table test_tab
/

Previous Topic: Invalid number while concatenating
Next Topic: Alias Used in Start by Connect with Program gives Error
Goto Forum:
  


Current Time: Fri Aug 22 04:26:17 CDT 2025