oracle 如何寻找最顶层父类
发布网友
发布时间:2024-09-28 04:09
我来回答
共3个回答
热心网友
时间:2024-11-26 08:47
可以设计成有层级的序列号,最顶级找0101就可以了
no id_sj id_bj jc
000 01 1
001 01 0101 2
002 0101 010101 3
003 010101 01010101 4
如何结构不能变,还是如下方式,而且当前层级是几级都不知道,就用循环吧
PS:001怎么还有上级编码1?到底顶级在哪里?
no id_sj id_bj
001 1 2
002 2 3
003 3 4
v_id_bj:=4;
while v_id_sj is not null loop
select id_sj into v_id_sj from tb where id_bj = v_id_bj;
select id_bj into v_id_bj from tb where id_bj = v_id_sj;
end loop;
热心网友
时间:2024-11-26 08:47
stream.close();
inStream.close();
text.setText(stream.toString());
Toast.makeText(MyActivity.this,"Loaded",Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e){
return ;
}
}
热心网友
时间:2024-11-26 08:48
结题了??SQL如下:
WITH T AS
(SELECT '001' ID, 1 PARENT, 2 SON FROM DUAL
UNION ALL
SELECT '002' ID, 2 PARENT, 3 SON FROM DUAL
UNION ALL
SELECT '003' ID, 3 PARENT, 4 SON FROM DUAL)
SELECT T.*, CONNECT_BY_ROOT(T.ID)
FROM T
START WITH ID = '001'
CONNECT BY PARENT = PRIOR SON
ORDER BY ID;