Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 790977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:45:41+00:00 2026-05-14T21:45:41+00:00

Using Oracle 11g release 2, the following query gives an ORA-01790: expression must have

  • 0

Using Oracle 11g release 2, the following query gives an ORA-01790: expression must have same datatype as corresponding expression:

with intervals(time_interval) AS
 (select trunc(systimestamp)
    from dual
  union all
  select (time_interval + numtodsinterval(10, 'Minute'))
    from intervals
   where time_interval < systimestamp)
select time_interval from intervals;

The error suggests that the datatype of both subqueries of the UNION ALL are returning different datatypes.

Even if I cast to TIMESTAMP in each of the subqueries, then I get the same error.

What am I missing?

EDIT: I’m not looking for a CONNECT BY replacement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:45:42+00:00Added an answer on May 14, 2026 at 9:45 pm

    In my opinion, “Recursive Subquery Factoring” is broken in 11g R2 for queries with date or timestamp column.

    with test(X) as
    (
      select to_date('2010-01-01','YYYY-MM-DD') from dual
      union all (
        select (X + 1) from test where X <= to_date('2010-01-10','YYYY-MM-DD') 
      )
    )
    select * from test;
    
    ORA-01790
    

    use a cast to convert the datatype:

    with test(X) as
    (
      select cast(to_date('2010-01-01','YYYY-MM-DD') as date) from dual
      union all (
        select (X + 1) from test where X <= to_date('2010-01-10','YYYY-MM-DD') 
      )
    )
    select * from test;
    
    X
    -------------------
    2010-01-01 00:00:00
    
    1 row selected
    

    Casting a date into a date is helping, but where are the other results?

    It gets even better…

    Try it with another start date:

    with test(X) as
    (
      select cast(to_date('2007-01-01','YYYY-MM-DD') as DATE) from dual
      union all (
        select (X + 1) from test where X <= to_date('2011-01-11','YYYY-MM-DD') 
      )
    )
    select * from test 
    where rownum < 10; -- important!
    
    X
    -------------------
    2007-01-01 00:00:00
    2006-12-31 00:00:00
    2006-12-30 00:00:00
    2006-12-29 00:00:00
    2006-12-28 00:00:00
    2006-12-27 00:00:00
    2006-12-26 00:00:00
    2006-12-25 00:00:00
    2006-12-24 00:00:00
    
    9 rows selected
    

    Counting backwards? Why?

    Update 14-Jan-2014: As a workaround, use the CTE starting with the end date and building the recursive CTE backwards, like this:

    with test(X) as
    (
      select cast(to_date('2011-01-20','YYYY-MM-DD') as DATE) as x from dual
      union all (
        select cast(X - 1 AS DATE) from test 
        where X > to_date('2011-01-01','YYYY-MM-DD') 
      )
    )
    select * from test 
    

    Results:

    |                              X |
    |--------------------------------|
    | January, 20 2011 00:00:00+0000 |
    | January, 19 2011 00:00:00+0000 |
    | January, 18 2011 00:00:00+0000 |
    | January, 17 2011 00:00:00+0000 |
    | January, 16 2011 00:00:00+0000 |
    | January, 15 2011 00:00:00+0000 |
    | January, 14 2011 00:00:00+0000 |
    | January, 13 2011 00:00:00+0000 |
    | January, 12 2011 00:00:00+0000 |
    | January, 11 2011 00:00:00+0000 |
    | January, 10 2011 00:00:00+0000 |
    | January, 09 2011 00:00:00+0000 |
    | January, 08 2011 00:00:00+0000 |
    | January, 07 2011 00:00:00+0000 |
    | January, 06 2011 00:00:00+0000 |
    | January, 05 2011 00:00:00+0000 |
    | January, 04 2011 00:00:00+0000 |
    | January, 03 2011 00:00:00+0000 |
    | January, 02 2011 00:00:00+0000 |
    | January, 01 2011 00:00:00+0000 |
    

    Test conducted with:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Oracle 11g, I have the following LDAP string which is only a subset
I have the following query which is giving me an ORA-00935 missing expression error,
I am using oracle 11g and have a table with an XMLType. There are
I am using oracle 11g and have written a stored procedure which stores values
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I have looked through the whole set of Oracle Database 11g Release 2 (11.2)
I am using Oracle 11g, and I have a lot of stored procedure code
I am usung oracle 11g. Suppose the following query returns n rows. SELECT t.id,t.from_date,t.price
I'm using Oracle 11g R2. I have a table with 9.1 billion rows. When
On an Oracle 11g engine using PL/SQL I have logic that runs like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.