Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    50

    Arrow Unanswered: create a string from all the records

    Hi,
    How can I create a long string from all the records fetched from the query.

    For E.g. , If my query returns 5 records

    AA
    BB
    CC
    DD
    EE

    Then I want to make a string like AA~BB~CC~DD~EE.

    This sting I want to make in the query itself and dont want to do that using a cursor.

    Thanks,

    Ishan

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

  3. #3
    Join Date
    Mar 2004
    Posts
    50
    thanks a lot tony.
    Your knowledge has always surprised me.


    Ishan

  4. #4
    Join Date
    Jul 2003
    Posts
    2,296
    just create a transposing function (from asktom).
    PHP Code:
    create or replace
    function get_transposedp_a in varchar2 )
    return 
    varchar2
    is
        l_str  varchar2
    (4000) default null;
        
    l_sep  varchar2(1) default null;
    begin
        
    for x in (    select col_b a from tab_a where col_a p_a )
        
    loop
           l_str 
    := l_str || l_sep || x.;
          
    l_sep := '~';
        
    end loop;
        return 
    l_str;
    end;
    /


      
    1  select col_a,get_transposed(col_ab from tab_a
      2
    group by col_a
    topicadm
    @Topic_Dev> /

    CO B
    -- --------------------
    1  AA~BB~CC~DD 
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •