Flatten the recursive hierarchy
HelloI am trying to flatten a recursive hierarchy like this table:
Source:
KEY... PARENT_KEY... NAME... LEVEL
1 ........... (NULL)................... ABC............ 1
2 .......... 1...........................123............2
3 .......... 1...........................456............2
4 ......... 3...........................xyz............. 3
Target:
KEY... NAME_LEVEL1... NAME_LEVEL2... NAME_LEVEL3
1 ........ ABC...................... ABC...................... ABC
2 ........ ABC...................... 123, 123
3 ........ ABC...................... ... 456 456
4 ........ ABC...................... 456... xyz
I tried to use the CONNECT BY clause to flatten out it, but I'm stuck trying to get the third level. Here's my query:
Select name, previous name
source
Start with parent_key is null
connect by prior key = parent_key;
Is it possible to get all the names of level 3 in a single query? Maybe connect you by is the wrong thing to use here?
Thank you
Hello
CONNECTION is good for this, because it allows us to use the SYS_CONNECT_BY_PATH:
SELECT key
, NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 1), name) AS name_level_1
, NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 2), name) AS name_level_2
, NVL (REGEXP_SUBSTR (SYS_CONNECT_BY_PATH (name, '/'), '[^/]+', 1, 3), name) AS name_level_3
FROM source
START WITH parent_key IS NULL
CONNECT BY parent_key = PRIOR key
;
This requires that you know some characters that never occurs in the name. I used "/" above, but you can use any character.
I hope that answers your question.
If not, post CREATE TABLE and INSERT statements for your sample data, as well as an explanation of how you get the desired results.
Tags: Database
Similar Questions
-
Flatten the recursive XML tree
Hello
I'm trying to parse some XML and flatten for further processing. Using a variation on the code in this post [url http://forums.oracle.com/forums/thread.jspa?threadID=2210708 & tstart = 0] (thanks odie_63!) I can get insofar as:
Gives meCREATE TABLE xml_test OF XMLType; INSERT INTO xml_test VALUES(XMLType('<Node>Text<Condition>CondType1<From>XX</From> <To>YY</To> </Condition> <Node>Child1<Condition>CondType2<Type>0</Type> <Number>12,34,56,89,0012</Number> </Condition> <Node>Child2<Condition>CondType3<From>Mon</From> <To>Fri</To> </Condition> <Tariff>Fee<Price>50</Price></Tariff> <Tariff>Rate<Price>10</Price><Interval>60</Interval></Tariff> </Node> <Node>DefaultRate<Tariff>Fee<Price>5000</Price></Tariff></Node> </Node> </Node>')); COMMIT; SELECT x.* FROM xml_test xt, XMLTable( 'declare function local:getID($e as node()) as xs:integer { for $i at $j in $d/descendant::* where $i is $e return $j } ; declare function local:getConditions($c as node()) as element()* { for $cond in $c/child::Condition return element r { element condtype1_from { if ($cond/text() = "CondType1") then $cond/From/text() else () }, element condtype1_to {if ($cond/text() = "CondType1") then $cond/To/text() else ()}, element condtype2_type { if ($cond/text() = "CondType2") then $cond/Type/text() else () }, element condtype2_number {if ($cond/text() = "CondType2") then $cond/Number/text() else ()}, element condtype3_from { if ($cond/text() = "CondType3") then $cond/From/text() else () }, element condtype3_to {if ($cond/text() = "CondType3") then $cond/To/text() else ()} } }; declare function local:getTariff($tariff as node()) as element()* { for $t in $tariff/child::Tariff return element r { element fee_price {if ($t/text() = "Fee") then $t/Price/text() else ()}, element rate_price {if ($t/text() = "Rate") then $t/Price/text() else ()}, element rate_interval {if ($t/text() = "Rate") then $t/Interval/text() else ()} } }; declare function local:getChildren($e as node(), $pID as xs:integer?) as element()* { for $i in $e/child::Node let $ID := local:getID($i) let $c := local:getConditions($i) let $t := local:getTariff($i) return element r { element tag_id {$ID}, element parent_tag_id {$pID}, element tag_name {local-name($i)}, element tag_text {$i/text()}, element attr_list {string-join(for $j in $i/@* return concat(local-name($j),''="'',$j,''"'')," ")}, element condtype1_from { $c/condtype1_from }, element condtype1_to { $c/condtype1_to }, element condtype2_type { $c/condtype2_type }, element condtype2_number { $c/condtype2_number }, element condtype3_from { $c/condtype3_from }, element condtype3_to { $c/condtype3_to }, element fee_price { $t/fee_price }, element rate_price { $t/rate_price }, element rate_interval { $t/rate_interval } } | local:getChildren($i,$ID) }; local:getChildren($d,())' passing xt.object_value as "d" columns tag_id number path 'tag_id', parent_tag_id number path 'parent_tag_id', tag_name varchar2(50) path 'tag_name', tag_text VARCHAR2(50) path 'tag_text', attr_list varchar2(4000) path 'attr_list', condtype1_from varchar2(100) path 'condtype1_from', condtype1_to varchar2(100) path 'condtype1_to', condtype2_type varchar2(100) path 'condtype2_type', condtype2_number varchar2(100) path 'condtype2_number', condtype3_from varchar2(100) path 'condtype3_from', condtype3_to varchar2(100) path 'condtype3_to', fee_price number path 'fee_price', rate_price number path 'rate_price', rate_interval number path 'rate_interval' ) x;
I don't see how reach (whether via XML or SQL right - recursion or same PL/SQL) is how to flatten slightly further given the rules:TAG_ID PARENT_TAG_ID TAG_NAME TAG_TEXT CONDTYPE1_FROM CONDTYPE1_TO CONDTYPE2_TYPE CONDTYPE2_NUMBER CONDTYPE3_FROM CONDTYPE3_TO FEE_PRICE RATE_PRICE RATE_INTERVAL ---------------------- ---------------------- ---------- ------------ -------------- ------------ ---------------------- -------------------- -------------- ------------ ---------------------- ---------------------- ---------------------- 1 Node Text XX YY 5 1 Node Child1 0 12,34,56,89,0012 9 5 Node Child2 Mon Fri 50 10 60 18 5 Node DefaultRate 5000
< li > three types of node is node, Condition and price.
< li > node A is always the starting point and can have zero, one or several Conditions and may have more than one node at the same level.
< li > after the crossing of all nodes and Conditions will end one or two nodes in tariff.
< li > I want to consolidate the conditions where they appear at different levels for a fee (to be delimited by a character, for example a 'C').
< li > the "tag_text" should come together to form the unique path to the tariff.
< li > A node that ends in a tariff grid is not all child nodes more of any type.
The output I want aim (above) would be:
I would really, really appreciate any input on this one because I think I looked at it for far too long... I'm almost there still can not quite end the.TAG_ID PARENT_TAG_ID TAG_NAME TAG_TEXT CONDTYPE1_FROM CONDTYPE1_TO CONDTYPE2_TYPE CONDTYPE2_NUMBER CONDTYPE3_FROM CONDTYPE3_TO FEE_PRICE RATE_PRICE RATE_INTERVAL ---------------------- ---------------------- ---------- ------------------------- -------------- ------------ ---------------------- -------------------- -------------- ------------ ---------------------- ---------------------- ---------------------- 1 Node /Text/Child1/Child2 XX YY 0 12,34,56,89,0012 Mon Fri 50 10 60 18 Node /Text/Child1/DefaultRate XX YY 0 12,34,56,89,0012 5000
Thank you very much
Gareth.Hi Gareth,
- I want to consolidate the conditions where they appear at different levels for a fee (to be delimited by a character, for example a 'C').
Could you give an example? It shall apply on the sample?
Additional question:
On the final output, you still need TAG_ID, PARENT_TAG_ID and TAG_NAME?If I understand what you're after, a quick way is to use a CONNECT BY clause directly on your existing query:
SELECT sys_connect_by_path(x.tag_text, '/') as tag_text , sys_connect_by_path(x.condtype1_from, '/') as condtype1_from , sys_connect_by_path(x.condtype1_to, '/') as condtype1_to , sys_connect_by_path(x.condtype2_type, '/') as condtype2_type , sys_connect_by_path(x.condtype2_number, '/') as condtype2_number , sys_connect_by_path(x.condtype3_from, '/') as condtype3_from , sys_connect_by_path(x.condtype3_to, '/') as condtype3_to , x.fee_price , x.rate_price , x.rate_interval FROM xml_test xt, XMLTable( 'declare function local:getID($e as node()) as xs:integer { for $i at $j in $d/descendant::* where $i is $e return $j } ; declare function local:getConditions($c as node()) as element()* { for $cond in $c/child::Condition return element r { element condtype1_from { if ($cond/text() = "CondType1") then $cond/From/text() else () }, element condtype1_to {if ($cond/text() = "CondType1") then $cond/To/text() else ()}, element condtype2_type { if ($cond/text() = "CondType2") then $cond/Type/text() else () }, element condtype2_number {if ($cond/text() = "CondType2") then $cond/Number/text() else ()}, element condtype3_from { if ($cond/text() = "CondType3") then $cond/From/text() else () }, element condtype3_to {if ($cond/text() = "CondType3") then $cond/To/text() else ()} } }; declare function local:getTariff($tariff as node()) as element()* { for $t in $tariff/child::Tariff return element r { element fee_price {if ($t/text() = "Fee") then $t/Price/text() else ()}, element rate_price {if ($t/text() = "Rate") then $t/Price/text() else ()}, element rate_interval {if ($t/text() = "Rate") then $t/Interval/text() else ()} } }; declare function local:getChildren($e as node(), $pID as xs:integer?) as element()* { for $i in $e/child::Node let $ID := local:getID($i) let $c := local:getConditions($i) let $t := local:getTariff($i) return element r { element tag_id {$ID}, element parent_tag_id {$pID}, element tag_name {local-name($i)}, element tag_text {$i/text()}, element condtype1_from { $c/condtype1_from }, element condtype1_to { $c/condtype1_to }, element condtype2_type { $c/condtype2_type }, element condtype2_number { $c/condtype2_number }, element condtype3_from { $c/condtype3_from }, element condtype3_to { $c/condtype3_to }, element fee_price { $t/fee_price }, element rate_price { $t/rate_price }, element rate_interval { $t/rate_interval } } | local:getChildren($i,$ID) }; local:getChildren($d,())' passing xt.object_value as "d" columns tag_id number path 'tag_id', parent_tag_id number path 'parent_tag_id', tag_name varchar2(50) path 'tag_name', tag_text varchar2(50) path 'tag_text', condtype1_from varchar2(100) path 'condtype1_from', condtype1_to varchar2(100) path 'condtype1_to', condtype2_type varchar2(100) path 'condtype2_type', condtype2_number varchar2(100) path 'condtype2_number', condtype3_from varchar2(100) path 'condtype3_from', condtype3_to varchar2(100) path 'condtype3_to', fee_price number path 'fee_price', rate_price number path 'rate_price', rate_interval number path 'rate_interval' ) x WHERE connect_by_isleaf = 1 CONNECT BY prior tag_id = parent_tag_id START WITH parent_tag_id IS NULL ; TAG_TEXT CONDTYPE1_FROM CONDTYPE1_TO CONDTYPE2_TYPE CONDTYPE2_NUMBER CONDTYPE3_FROM CONDTYPE3_TO FEE_PRICE RATE_PRICE RATE_INTERVAL ------------------------------ ---------------- -------------- ---------------- --------------------- ---------------- -------------- ---------- ---------- ------------- /Text/Child1/Child2 /XX// /YY// //0/ //12,34,56,89,0012/ ///Mon ///Fri 50 10 60 /Text/Child1/DefaultRate /XX// /YY// //0/ //12,34,56,89,0012/ /// /// 5000
Here I used the SYS_CONNECT_BY_PATH function to aggregate the values in the pecking order. You can change the separator and use string manipulation functions more format the result.
This can also be done directly in XQuery. So if you could answer the two questions above then I could show you how.
-
I work with files in a folder tree. I want to browse this folder hierarchy, just as I did in the original copy of Windows Explorer in Windows XP. I want to use the arrow keys to navigate up and down, and when I'm in a folder and click the previous button, I want it to go up one level in the folder hierarchy, just like he used to.
Now, when I hit the 'back' button, Windows Explorer behaves as a browserand goes to the last folder that I have read.
It's so frustrating! She interrupts my thought process and the movement of my work. If I wanted to use a browser, I use Internet Explorer.
How Windows Explorer can be configured to browse the folder hierarchy instead of behaving like a browser? Remember the "unwebified" of Windows XP Windows Explorer version? This is what I want so I can get back to work effectively.
Windows Explorer 7 does not have the up button like XP, however, in the address bar you can select the folder in the hierarchy (sometimes called the trail of bread crumbs) to return.
Windows 8 added the arrow pointing upwards.
-
Problem with the Navigator hierarchy
Hello
I installed Navigator hierarchy according to the description in the installation guide, which is
1. install the Denorm hierarchy (Scripts apply then pitch the series up)
2. installation of the navigation hierarchy (Scripts apply then pitch the series up)
and all the results of running the script has been directed by the specified page.
After installation, I went to tool > > Navigator hierarchy and nothing is displayed, the icon I got is 'Globe' instead of the one mentioned in the document, is there something I'm missing?
Thank you
I solved the problem and get the browser hierarchy as expected with all the expected results.
I did as a result of things to solve the problem:
1. redeploy the files from v6.1.1\Web to v6.1.0\web.
2 uninstall denorm and navigator.
3. suppression of the story earlier version generated scripts.
4. apply the hierarchy Denorm scripts, Service restarts and IISRest.
5. installation Denorm Setup, restart the Service.
6. application of browser scripts. Restart the service.
7 installation installation and restart the Service.
-
Is there a shortcut key for "Flatten Image"? I just upgraded to CC and again it is not a shortcut for IT... Ugh. Someone knows something to flatten the Image via the keyboard?
I've been using Ctrl + Alt + Shift + F for years, don't know if it's a default shortcut, or if I assigned.
You can create your own sets of shortcuts - Edition > keyboard shortcuts.
-
What is the difference between the layers of the merger, flatten the layers & merge down? How can I know which to use?
Flatten makes them your image into one with a background color, regardless of the color is in your color chart 2 in the toolbar (foreground/background). Merge Visible and merge down is like that... they flatten the image, they just composite whatever you choose. If you merge down, it takes a top and a bottom. If you are merge visible to all those with the eyeball of visibility 'on' and composites them. The main thing is that they don't flatten your image, so if you have layers with transparency transparency is preserved. Flatten transparency of deletes it.
-
I found flatten java script, but making my useless button and flatten the entire document.
I also found that the actions of document to check
for (var i = 0; i < this.numFields; i ++) {}
fieldName var = this.getNthFieldName (i);
field var = this.getField (fieldName);
If (field.value.length == 0)
{
field.setFocus)
App.Alert ("Field" fieldName + "is required.) Please enter a value. »)
}
}
but I do still need to flatten + send to an e-mail recipient. Is it possible to do all these steps with just one button? Or save the form as being "read" only.
IM currently using Acrobat XI
Invoke the var = new Array ("AFieldName... 1','AFieldName... 2", ".....");
var cFieldName = «»
var ok = true
for (var i = 0; i)< afields.length;="" i++)="">cFieldName = this.getField (aFields [i])
If (cFieldName.value == "") {}OK = false
cFieldName.setFocus)
App.Alert ("field [" + cFieldName.name + "] is required. ') Please enter a value. »)}
}If (ok == true) {}
for (var i = 0; i)< this.numfields="" ;="" i++)="">
var f = this.getField (this.getNthFieldName (i));
If (f == null) continue;
f.ReadOnly = true
}this.mailDoc({)
cTo: "[email protected]."
bassujetti: "your subject...". »,
CMSG: "dear...". »
})
} -
Flatten the data in, SELECT
Oracle 11 g 2
Linux Mint
==========
In light of the following:
create table grades_detail (school_year char (4),
grade char(1),
grade_desc 40,
constraint pk_grades_detail primary key (school_year, grade));create table class_grades_detail (student, char (6),)
school_year char (4),
class1_grade char (1),
class2_grade char (1),
class3_grade char (1),
class4_grade char (1),
constraint pk_class_grades_detail primary key (student, school_year));
insert into grades_detail values ('2013', 'A', 'Excellent');
insert into grades_detail values ("2013", 'B', 'Good');
insert into grades_detail values ("2013", 'C', 'Medium');
insert into grades_detail values ('2013 ',' d ", 'Poor');
insert into grades_detail values ("2013", 'F', 'Bankrupt');insert into class_grades_detail values ('1001', '2013', 'A', ",", ");
insert into class_grades_detail values ('1002 ', ' 2013', ","B",",");
insert into class_grades_detail values ('1003 ', ' 2013', ",", "C", ");
insert into class_grades_detail values ('1004 ', ' 2013', ",",", ');
insert into class_grades_detail values ('2005', '2013', 'A', ","C",");
insert into class_grades_detail values ('2006', '2013', 'A', ",", 'F');
insert into class_grades_detail values ('2007', '2013',' A ',' B', ",");
insert into class_grades_detail values ('2008', "2013" ", would be", ", had ',");and given the following SQL code:
Select class_grades_detail.student
class_grades_detail.school_year
class_grades_detail.class1_grade
class_grades_detail.class2_grade
class_grades_detail.class3_grade
class_grades_detail.class4_grade
grades_detail.grade_desc
of class_grades_detail
class_grades_detail.school_year left join grades_detail = grades_detail.school_year
and (class_grades_detail.class1_grade = grades_detail.grade
or class_grades_detail.class2_grade = grades_detail.grade
or class_grades_detail.class3_grade = grades_detail.grade
or class_grades_detail.class4_grade = grades_detail.grade);How 'flatten' the data to get a result like below?
(Yes, I know the SQL above has not all the columns in gradeX_desc below, but that's what I'm aiming for - a column for each class descr.) However, the SQL above will show you the data as it appears currently):
student, school_year, class1_grade, grade1_desc, class2_grade, grade2_desc, class3_grade, grade3_desc, class4_grade grade4_desc
1001 2013 A B excellent C good average poor D
With the SQL above I have not (of course) get it. Yes, I think to Swivel, but could not get this to work. Even tried to DECODE.
Any help would be appreciated.
select distinct cgd.student, cgd.school_year, MAX(cgd.class1_grade) g1, MAX(gd1.grade_desc ) grade1, MAX(cgd.class2_grade) g2, MAX(gd2.grade_desc ) grade2, MAX(cgd.class3_grade) g3, MAX(gd3.grade_desc ) grade3, MAX(cgd.class4_grade) g4, MAX(gd4.grade_desc ) grade4 from class_grades_detail cgd, grades_detail gd1, grades_detail gd2, grades_detail gd3, grades_detail gd4 where gd1.school_year(+) = cgd.school_year and gd2.school_year(+) = cgd.school_year and gd3.school_year(+) = cgd.school_year and gd4.school_year(+) = cgd.school_year and gd1.grade(+) = cgd.class1_grade and gd2.grade(+) = cgd.class2_grade and gd3.grade(+) = cgd.class3_grade and gd4.grade(+) = cgd.class4_grade group by cgd.student, cgd.school_year
STUDENT SCHOOL_YEAR G1 G2 G3 G4 GRADE4 GRADE3 GRADE2 GRADE1
------- ----------- -- ------------ -- ------------ -- ------------ -- ------------
Good 1002 2013 B
2006 2013 A F excellent Fail
Good 2007-2013 has excellent B
1004 2013 D Poor
1001 2013 has excellent
2008 2013 D D poor poor
1003 2013 C average
2005-2013 A C average excellent
8 selected lines.
-
In Adobe Acrobat XI Pro Version 11.0.0 I use the option flatten under control up front, but when I return in the document using Acrobat and use the change text and Images, I am able to edit and delete items in the document. I also tried flattening Preview-> apply, but it does not work either. Finally, I tried to print the document in pdf format, but the same thing happens. If a document is flattened, it is not editable by any software, but it seems that if someone has Acrobat, they will be able to edit the pdf file I send them. Can you please tell me how I can really flatten a pdf file so that it is not editable by all?
If you want editable by any software from Adobe, you can add security when you flatten the document.
-
OBIEE 11 g with BI Apps EBS: how to load the Product hierarchy?
Hi gurus,
We are implementing BI 7.9.6.3 applications [OBIEE 11.1.1.1.5 with EBS modules].
We have implemented all the configurations and mappings in Informatica. But after complete loading ETL. The Product hierarchy view all null.
Currently, we are studying it. Anyone with experience points can we what are possible places to look for?
Is this something that we need to set up SDE_Universal_ProductDimension of SDE_Universal_Adaptor. Currently, it is not configured.
Any ideas will be greatly appreciated.
Concerning
NathalieNo you don't need to touch any of the mappings 'universal '.
Check this Metalink note:
Product hierarchy is not filled in OBIA 7.9.6 with EBS R12.1.1 as source [1110185.1 ID]
So useful, pls mark as correct or useful
-
Where can I find a tutorial on the folder hierarchy show?
I have 11 items first, which is also the organizer of the program elements. And I also have Photoshop Elements 10. The organizer elements with video editing software, that's what I'm interested in good. I think that my folder hierarchy is not fair. I want to straighten but I don't know how. Can someone direct me to a tutorial on how to work with the folder hierarchy.
This could be another issue, but it could be related to my confusion about the folder hierarchy in the Organizer. On June 10 I was copying some photos from my hard drive to the Organizer - probably a stupid thing to do. While I was doing this, the pictures folder (display and organize digital images) not is more took me to all my photos on the hard drive. The pictures folder's subfolders, Documents, music, Control Panel on the Windows 7 Desktop to the right of the menu stuff start.
When I click on images now I get two files: Adobe and photos. The Adobe file has these values - size: 0 bytes; Contains: 0 files, 1 folder; Created the: Monday, June 10, 2013; Attributes: Read-only (applies only to files in the folder. I deleted the folder Adobe several times but he returns.
What I really want to do, is to restore my folder image to its original state so that I have access to all the photos of my HDD immediately instead of clicking around these issues. Vaguely, I think that something I did to the folder hierarchy in the optimizer has messed up things on my computer.
Of what you have listed here, it looks like you have moved your records photo up to a level... sort of. I don't know why computer appears in my images (or perhaps there is just one problem with the way you have indented the list here...). But it looks like you have a lot of your image files moved to the parent folder where one normally would expect them to be.
The folder my pictures is the name used by Windows XP, Windows Vista and later, the record was simply named images. If I read your right of the list, it looks like you want to take the faces folder that is located in the folder of Tommy and move it to the pictures folder (the one at the bottom of the list, just above D, E, F, G). You will also need to move the folder of Clowns (to the top of the list), in the case of faces that you've just moved in the previous step. If there are images in my pictures, pictures files and/or the faces (the three all at the top of the list), you will want to move them to the folder of images at the bottom of the list.
All this can be done in the elements Organizer, simply drag and drop a folder to move it from where it is at the location you want.
For any questions with the help of the elements of first, you'll want to post in the forum first parts of responses: http://forums.adobe.com/community/premiere_elements
-
TIFF of Import Options - flatten the layers into a single Image
Hi all
Running a script to open the files and convert them into another type. When it comes to a TIFF file type, called 'TIFF Import Options' dialog box opens. This window has a column of Options containing two pieces of music radio to "Convert layers to objects" and "flatten into a single Image. How to open the file with the whole "flatten the layers into a single image?
Thank you
OpenOptionsPhotoshop.preserveLayers = true;
-
The recursive subquery factoring vs hierarchical query
Experts,
Here it is two queries, I'm executing using hierarchical of recursive subquery and new classical approach. Problem came out was different for the recursive subquery factoring, as this is not displayed parent-child approach, while forwards connect shows parent-child mode. Query 1, I use hierarchical as show good output parent-child, is approaching the 2 query displays all of the nodes of level 1 and then level 2 nodes. I want the query 2 output to be the same as query 1. change query 2 as required.
Note: the output of the two queries post as in sqlplus and toad. Please copy and use in your command prompt.
QUERY 1:
with the hand in the form (select 1 id, name 'John', null, mgrid Union double all the)
Select 2 id, the name of 'michael', null, mgrid Union double all the
Select 3 id, the name of "peter", null, mgrid Union double all the
Select 4 id, the name of "henry", 1 mgrid Union double all the
Select 5 id, "nickname", mgrid 2 Union double all the
Select 6 id, "pao" name, mgrid 3 of all the double union
Select 7 id, the name of 'kumar', mgrid 3 of all the double union
Select 8 id, the name 'parker', mgrid 3 of all the double union
Select 9 id, the name of "mike", 5 double mgrid),
Select lpad (' ', 2 *(level-1)). name, key start with mgrid level is null connect by prior id = mgrid.
OUTPUT:
LEVEL NAME
------------------------------ ----------
John 1
Henry 2
Michael 1
Nick 2
Mike 3
Stone 1
PAO 2
Kumar 2
Parker 2
9 selected lines.
QUERY 2:
with the hand in the form (select 1 id, name 'John', null, mgrid Union double all the)
Select 2 id, the name of 'michael', null, mgrid Union double all the
Select 3 id, the name of "peter", null, mgrid Union double all the
Select 4 id, the name of "henry", 1 mgrid Union double all the
Select 5 id, "nickname", mgrid 2 Union double all the
Select 6 id, "pao" name, mgrid 3 of all the double union
Select 7 id, the name of 'kumar', mgrid 3 of all the double union
Select 8 id, the name 'parker', mgrid 3 of all the double union
Select 9 id, the name of "mike", 5 double mgrid),
/ * Select lpad (' ', 2 *(level-1)). name, key start with mgrid level is null connect by prior id = mgrid. * /
secmain (id, name, mgrid, hierlevel) as (select id, name, mgrid, 1 hierlevel of the main where mgrid is null
Union of all the
Select m.id, $m.name, m.mgrid, sm.hierlevel + 1 in m main join secmain sm on(m.mgrid=sm.id))
cycle is_cycle set id 1 default 0
Select lpad (' ', 2 *(hierlevel-1)). name, secmain hierlevel.
OUTPUT:
NAME HIERLEVEL
------------------------------ ----------
John 1
Michael 1
Stone 1
Henry 2
Nick 2
Parker 2
Kumar 2
PAO 2
Mike 3
9 selected lines.For example
SQL> with main as(select 1 id,'john' name,null mgrid from dual union all 2 select 2 id,'michael' name,null mgrid from dual union all 3 select 3 id,'peter' name,null mgrid from dual union all 4 select 4 id,'henry' name,1 mgrid from dual union all 5 select 5 id,'nick' name,2 mgrid from dual union all 6 select 6 id,'pao' name,3 mgrid from dual union all 7 select 7 id,'kumar' name,3 mgrid from dual union all 8 select 8 id,'parker' name,3 mgrid from dual union all 9 select 9 id,'mike' name,5 mgrid from dual), 10 secmain (id,name,mgrid,hierlevel) as 11 (select id,name,mgrid,1 hierlevel from main 12 where mgrid is null 13 union all 14 select m.id,m.name,m.mgrid,sm.hierlevel+1 from main m join secmain sm on(m.mgrid=sm.id)) 15 search depth first by name set seq 16 cycle id set is_cycle to 1 default 0 17 select lpad(' ',2*(hierlevel-1))||name name,hierlevel from secmain order by seq; NAME HIERLEVEL ---------- ---------- john 1 henry 2 michael 1 nick 2 mike 3 peter 1 kumar 2 pao 2 parker 2 9 rows selected. SQL>
Published by: Dom Brooks on November 23, 2011 13:52
Edited for the scope of the search and detection of cycle -
Flatten the images in PDF format?
Hello world
Well, I sent my design work (used illustrator CS4) to compensate for the printer and it came out a photo dropped.
Beucase 'the pdf was not flattened,' says the offset press.
Now, I need to send back to them and I was wondering if you could help me to avoid the same problem happening again...
How should I "flatten" the PDF?
Searched for solutions but don't know exactly what procedure I have to do.
Thank you guys.
Use the Flattener Preview and control upstream in Acrobat...
Mylenium
-
grouping with the parent hierarchy
Hi all
I have data like this
existing layout:
trade oil
----------------
cust_A 100
cust_A 50
cust_B 20
presentation expected:
trade oil
-----------------
cust_A 150
cust_B 20
in the xml hierarchy, the invoice_type (trade oil) is one level below customer.
How can I solve this problem.
any advice will be highly appreciated.
rgrds,
TSEI sent you the modified model. Take a peek inside.
Thank you
Bipuser
Maybe you are looking for
-
My homepage a caps inside and Firefox guard return to non-caps.
My home page is a case-sensitive system. FIrefox keeps affecting upper non-caps. How can I fix it so Firefox load my homepage correctly?
-
How can I copy Pages and Numbers to ICloud by car?
I just upgraded my IPhone 6 Plus and my IMac (running OS X El Capitan) the reader to ICloud. I thought that my documents Pages and Numbers would be automatically copied in ICloud drive. They were not. How can I copy my documents Pages, and existin
-
Hello. I bought HP desktop a6345.sc about half a year ago and I noticed the lack of performance of the demanding graphics applications (video games, etc.) That's why I decided it's time for an upgrade. Performance index gives me "5.4" with the CPU an
-
SharePoint Designer 2007 cannot parse
I work with SharePoint Designer 2007 for my site and it works fine on my Windows 7 home computer and on a couple of different ones in my office. However, on my desk at work, I get an error message "could not parse. I tried put it back and still get
-
You can run Microsoft Security Essentials along the coast with Verizon internet suite? Or will they come into conflict.