![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, there is f.e. the following table: NAME FROM TO LENGTH 123456 O A 10 * 123456 A B 15 * 123456 B C 10 * 123456 C O 20 * 123456 B F 50 654321 O A 20 654321 A B 30 in the knode 123456 is a circle OABCO (see the *) and BF outside of this circle (all circles start with 'O'). knode 654321 has no circle at all. I need the result NAME CIRCLE CIRCLELENGTH 123456 OABCO 55 Is there a way to do this via SQL or do I need PLSQL? Thanks in advance Andreas -- wenn email, dann AndreasMosmann <bei> web <punkt> de |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi Michel, thank you ![]() Oracle Version 11.2.0.1.0 create table TKNODES (CNAME VARCHAR(10), CFROM CHAR(1), CTO CHAR(1), CLENGTH NUMBER(10,3)) / insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('123456','O','A',10); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('123456','A','B',15); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('123456','B','C',10); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('123456','C','O',20); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('123456','B','F',50); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('654321','O','A',20); insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values ('654321','A','B',30); -- wenn email, dann AndreasMosmann <bei> web <punkt> de |
#5
| |||
| |||
|
|
"Andreas Mosmann"<mosmann (AT) expires-30-09-2010 (DOT) news-group.org> a écrit dans le message de news: 1284559753.19 (AT) user (DOT) newsoffice.de... | Hi Michel, | | thank you ![]() | | Oracle Version 11.2.0.1.0 | | create table TKNODES (CNAME VARCHAR(10), CFROM CHAR(1), CTO CHAR(1), | CLENGTH NUMBER(10,3)) | / | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','O','A',10); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','A','B',15); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','B','C',10); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','C','O',20); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','B','F',50); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('654321','O','A',20); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('654321','A','B',30); | | | -- | wenn email, dann AndreasMosmann<bei> web<punkt> de SQL> select * from TKNODES order by cname; CNAME C C CLENGTH ---------- - - ---------- 123456 O A 10 123456 A B 15 123456 B C 10 123456 C O 20 123456 B F 50 654321 O A 20 654321 A B 30 SQL> select replace(sys_connect_by_path (cfrom, '/'), '/', '')||cto res 2 from tknodes 3 where connect_by_iscycle = 1 and cto = 'O' 4 connect by nocycle prior cname = cname and prior cto = cfrom 5 start with cfrom = 'O' 6 / RES ---------- OABCO Regards Michel |
#6
| |||
| |||
|
|
On 15.09.2010 17:01, Michel Cadot wrote: "Andreas Mosmann"<mosmann (AT) expires-30-09-2010 (DOT) news-group.org> a écrit dans le message de news: 1284559753.19 (AT) user (DOT) newsoffice.de... | Hi Michel, | | thank you ![]() | | Oracle Version 11.2.0.1.0 | | create table TKNODES (CNAME VARCHAR(10), CFROM CHAR(1), CTO CHAR(1), | CLENGTH NUMBER(10,3)) | / | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','O','A',10); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','A','B',15); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','B','C',10); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','C','O',20); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('123456','B','F',50); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('654321','O','A',20); | insert into TKNODES (CNAME,CFROM,CTO,CLENGTH) values | ('654321','A','B',30); | | | -- | wenn email, dann AndreasMosmann<bei> web<punkt> de SQL> select * from TKNODES order by cname; CNAME C C CLENGTH ---------- - - ---------- 123456 O A 10 123456 A B 15 123456 B C 10 123456 C O 20 123456 B F 50 654321 O A 20 654321 A B 30 SQL> select replace(sys_connect_by_path (cfrom, '/'), '/', '')||cto res 2 from tknodes 3 where connect_by_iscycle = 1 and cto = 'O' 4 connect by nocycle prior cname = cname and prior cto = cfrom 5 start with cfrom = 'O' 6 / RES ---------- OABCO Regards Michel + length(replace(sys_connect_by_path(lpad('x',clengt h,'x'),'/'),'/','')) as circlelength ;-) Best regards Maxim |
#7
| |||
| |||
|
|
"Maxim Demenko"<mdemenko (AT) gmail (DOT) com> a écrit dans le message de news: 4C913B74.1030107 (AT) gmail (DOT) com... | + length(replace(sys_connect_by_path(lpad('x',clengt h,'x'),'/'),'/','')) | as circlelength | | ;-) | | Best regards | | Maxim Indeed! I forgot the length. Regards Michel |
#8
| |||
| |||
|
|
Michel Cadot schreef: "Maxim Demenko"<mdemenko (AT) gmail (DOT) com> a écrit dans le message de news: 4C913B74.1030107 (AT) gmail (DOT) com... | + length(replace(sys_connect_by_path(lpad('x',clengt h,'x'),'/'),'/','')) | as circlelength | | ;-) | | Best regards | | Maxim Indeed! I forgot the length. Regards Michel The length of the circle, eh? It proves one is never too old to learn. |

![]() |
| Thread Tools | |
| Display Modes | |
| |