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 567579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:05:52+00:00 2026-05-13T13:05:52+00:00

I have a hierarchical query in Oracle 10 SQL that used to work. However,

  • 0

I have a hierarchical query in Oracle 10 SQL that used to work. However, I removed the materialized view it was based on, and now I can’t get it to come out properly, even leaving that view out altogether.

The original query looked like this:

select oh.name, oh.description
  , sys_connect_by_path(groupname, ':') "Groups"
  , (select count(*) 
      from ml.lastobsmv 
      where lastobsmv.hdid = oh.hdid) as obscount
from ml.obshead oh
  join ml.hiergrps hg on oh.groupid = hg.groupid
    connect by prior hg.groupid = hg.parentid

I presume it still works, but without the lastobsmv view, I can’t test it.

If I trim it down to

select oh.name, oh.description
from  ml.obshead oh
  join ml.hiergrps hg on oh.groupid = hg.groupid

it still works, returning 41K records. However, when I use the connect by clause, it goes out of control, returning millions of records (I usually have to cancel it before getting an accurate count).

select oh.name, oh.description
  , sys_connect_by_path(groupname, ':') "Groups"
from ml.obshead oh
  join ml.hiergrps hg on oh.groupid = hg.groupid
    connect by prior hg.groupid = hg.parentid

Am I missing something really blatant here, or am I misunderstanding the way this is supposed to work? Thanks.


Vadim,

It should return a list of Observation Terms along with the group they’re in. For example,

Obshead:

# CYCLE DAYS, number of days in menstrual cycle, 100

HierGrps:

100, 50, Gynecology
50, 10, Tx
10, 0, Basic

should produce

# CYCLE DAYS, number of days in menstrual cycle, :Basic:Tx:Gynecology

(eventually along with the number of times this obs term has been used, but I’ll worry about that later).

  • 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-13T13:05:52+00:00Added an answer on May 13, 2026 at 1:05 pm
    select
        oh.name,
        oh.description,
        hg."Groups"
    from
        obshead oh
        join ( select
                   groupid,
                   sys_connect_by_path( groupname, ':' ) "Groups"
               from
                   hiergrps
               start with
                   parentid = 0
               connect by
                   prior groupid = parentid
             ) hg
          on oh.groupid = hg.groupid
    

    Here’s the sample data I’ve used to test the query:

    create table obshead
    ( name varchar2(30)
    , description varchar2(30)
    , groupid number(3)
    );
    insert into obshead ( name, description, groupid )
         select 'Name One', 'Description One', 100 from dual union all
         select 'Name Two', 'Description Two', 200 from dual
    ;
    
    create table hiergrps
    ( groupid number(3)
    , parentid number(3)
    , groupname varchar2(30)
    );
    insert into hiergrps ( groupid, parentid, groupname )
         select 100, 50, 'Gynecology' from dual union all
         select  50, 10, 'Tx'         from dual union all
         select  10,  0, 'Basic'      from dual
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a typical SQL Server hierarchical query: WITH bhp AS ( SELECT name,
I have a hierarchical query to track a reporting structure. This almost works, except
In SQL server 2008 I have a hierarchical field (hierarchyid). How do I change
I have a class that contains hierarchical data. I want to present this data
I have some hierarchical data - each entry has an id and a (nullable)
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a class which models all categories and they can be ordered hierarchically.
I have a bunch of items in my program that all belong to a

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.