2、不定列行列转换 
如 
c1 c2 
-------------- 
1 我 
1 是 
1 谁 
2 知 
2 道 
3 不 
…… 转换为 
1 我是谁 
2 知道 
3 不 
用dbms_output输出每一行.

解决方案 »

  1.   

    以下为创建的表
    create table tt1
    (
      c1 number,
      c2 char(2)
    );insert into TT1 (C1, C2)
    values (1, '我');
    insert into TT1 (C1, C2)
    values (1, '是');
    insert into TT1 (C1, C2)
    values (1, '谁');
    insert into TT1 (C1, C2)
    values (2, '知');
    insert into TT1 (C1, C2)
    values (2, '道');
    insert into TT1 (C1, C2)
    values (3, '不');
    commit;
    请高手帮助想下,在线等
      

  2.   

    create or replace procedure irregular_switch
    as
       max_xh number;
       xh     number;
       str varchar2(4000);
    begin
      select max(c1) into max_xh from tt1;
      for xh in 1..max_xh loop
       for c in (select * from tt1 where c1=xh) loop
        str:=str||c.c2;
       end loop;
       dbms_output.put_line(xh ||'  '||str);
       str:='';
      end loop;
    end ;这种办法自己感觉不是太好.