Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
create a view with listagg of connect by hierarchy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jeff kish  
View profile  
 More options Oct 30 2012, 1:07 pm
Newsgroups: comp.databases.oracle.misc
From: jeff kish <kish...@gmail.com>
Date: Tue, 30 Oct 2012 10:07:59 -0700 (PDT)
Local: Tues, Oct 30 2012 1:07 pm
Subject: create a view with listagg of connect by hierarchy
Hi.

I have a table that includes these columns:
assetnum,description,parent.

Given any assetnum I can find its parent using the parent field. I can build a string showing the hierarchy for any given asset, say '268180' using this query:

select LISTAGG('(' || assetnum || ') ' || description, ' / ') WITHIN GROUP (order by level desc) "assetlist"  from asset start with assetnum = '268180' connect by prior parent = assetnum;

I'd like much to create a view which has this information for any asset, but I can't get my head around how to get it working.

I've tried various things such as
create view TEST as
select LISTAGG('(' || assetnum || ') ' || description, ' / ') WITHIN GROUP (order by level desc) "assetlist"  from asset start with assetnum = assetnum connect by prior parent = assetnum;

and

create view TEST as
select LISTAGG('(' || assetnum || ') ' || description, ' / ') WITHIN GROUP (order by level desc) "assetlist"  from asset start with parent = null connect by prior parent = assetnum;

but nothing is working. I'm having a conceptual problem here. Can someone help me out figuring the sql to create the view in oracle 11? Any explanation along the way is gratefully appreciated.

Jeff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeff kish  
View profile  
 More options Oct 30 2012, 8:02 pm
Newsgroups: comp.databases.oracle.misc
From: jeff kish <kish...@gmail.com>
Date: Tue, 30 Oct 2012 17:02:01 -0700 (PDT)
Local: Tues, Oct 30 2012 8:02 pm
Subject: Re: create a view with listagg of connect by hierarchy
I found this works fyi
Jeff

select a.assetnum, a.siteid,
(select LISTAGG('(' || b.assetnum || ') ' || b.description, ' / ')  WITHIN GROUP (order by level desc) "ASSETPARENTHIERARCHY"
from asset b start with assetnum = a.assetnum and siteid = '001' connect by prior parent = assetnum) ASSETPARENTHIERARCHY
from asset a


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »