效果
sql
SELECT LISTAGG(T.NAME, ' / ') WITHIN GROUP(ORDER BY LEVEL DESC) AS RESULT
FROM S_WORK_RESOURSE T
START WITH T.WORK_RESOURCE_NO = 323
CONNECT BY PRIOR T.PARENT_WORK_RESOURCE_NO = T.WORK_RESOURCE_NO
and T.PARENT_WORK_RESOURCE_NO is not null
后台应用
string GetLevelName_2 = @"SELECT LISTAGG(T.AREA_NAME, ' / ') WITHIN GROUP(ORDER BY LEVEL DESC) AS RESULT
FROM PRODUCE_EQUIPMENT_AREA T
START WITH T.ID = {0}
CONNECT BY PRIOR T.PARENT = T.ID
and T.PARENT is not null";
foreach (DataRow dr in v.Dt.Rows)
{
if (StringUtil.isNotNullOrBlank(dr["EI_CLS"]))
{
dt = DbUtil.QueryDT(string.Format(GetLevelName_1, dr["EI_CLS"]));
if (dt != null)
{
dr.BeginEdit();
dr["EI_CLS2"] = dt.Rows[0]["RESULT"].ToString();
dr.EndEdit();
}
}
}