maniupate data in a cursor or sql select
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: maniupate data in a cursor or sql select

  1. #1
    Join Date
    Apr 2002
    Posts
    29

    maniupate data in a cursor or sql select

    i am trying to read a column from a table that has 1's and 0's and want to translate it into T or F and then put it into a second table. My problem is.. how do i, when reading that table into a cursor, change 1's to T and 0's to F? here's the sample code i have so far.. i just need to add in the data manuplation somewhere but dont know where or how to do it. any ideas?


    v_1 name%TYPE;
    v_2 latest_time%TYPE;
    v_3 current_state%TYPE;

    CURSOR c_status IS
    select rdrx_des_table, rdrx_latest_time, rdrx_current_state
    from rdr_transfer;

    begin

    OPEN c_status;
    LOOP

    Fetch c_status into v_1, v_2, v_3;
    EXIT WHEN c_status%NOTFOUND;


    Insert into table2 (def_name, transfer_time, enabled)
    values (v_1, v_2, v_3);


    In the cursor, for v_3, it will fetch 1's or 0's, but before it's inserted into the 'enabled' column, i would like to change it to T or F. Thanks

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Use TRANSLATE or DECODE (or CASE).

    TRANSLATE(v_3, '10', 'TF')

    DECODE(v_3, 1, 'T', 'F')
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

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


Click Here to Expand Forum to Full Width