我有一个表tableA
LineID    Name    Inherit_ID  Parent
1          A         1           0
2          B         1,2         1
3          C         1,2,3       2表示一个树状结构,现在我想做一个查询,把inherit_id中的数字根据lineID换成Name,比如1,2,3换成A,B,C,这个SQL 怎么写?
如果一个SQL写不出的话使用包也可以,多谢!

解决方案 »

  1.   

    update table set name=replace(name,'1','A');
    update table set name=replace(name,'2','B');
    update table set name=replace(name,'3','C');
      

  2.   

    select sys_connect_by_path(name,',') path from start with Parent='0' connect by prior id =Parent;
      

  3.   

    倒,DECODE函数会不会用???
      

  4.   

    select decode(LineID,1,'A',2,'B',3,'C') from table
      

  5.   

    如果LineID是主键根据LineID创建游标
    v_LineID,v_Nameselect Name into v_Name from table1 where LineID = v_LineID;
    update table1 a 
    set inherit_id = replace(a.inherit_id,v_LineID,v_Name)
      

  6.   

    select decode(LineID,1,'A',2,'B',3,'C',LineID) from table...