DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: help inserting sequence into 5000 row table

  1. #1
    Join Date
    Apr 2001
    Location
    London
    Posts
    725

    help inserting sequence into 5000 row table

    Hi,

    I have 5000 row table. One of the columns in the table called tansactionno has no data in it.

    I want to create a sequence in that column starting at 10000 and ending at 15000. So each record has a unique identifier.

    i tried to create an anoynmous block using a cursor to select each record and update the transactionno with a variable, 1 is then added to the variable and the whole thing loops until 5000 records have been fetched.

    Unfortunately I am not a PL/SQL expert so am failing miserably with this.

    here is what I have so far.. can someone please help me correcting it. Your help is much appreciated!!!

    DECLARE
    x int;
    CURSOR csp_val_cur is
    select * from csp_temp_scy;
    csp_val_rec csp_val_cur%ROWTYPE;
    BEGIN
    x:=10000;
    OPEN csp_val_cur;
    LOOP
    FETCH csp_val_cur into csp_val_rec;
    EXIT WHEN NOT csp_val_cur%FOUND;
    update csp_temp_scy
    set transactionno = x;
    x:=x+1;
    END LOOP;
    commit;
    CLOSE csp_val_cur;
    end;
    Once you have eliminated all of the impossible,
    whatever remains however improbable,
    must be true.

  2. #2
    Join Date
    Apr 2001
    Location
    London
    Posts
    725
    Hi,

    solved this by inserting the data into a temporary table and inserting a sequence into a variable that was part of the record by record insert.

    would still know how it could be done with an uopdate thogh if anyone has the time.

    Thanks
    Once you have eliminated all of the impossible,
    whatever remains however improbable,
    must be true.

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    how about UPDATE foo SET idnumber = ROWNUM + 10000
    Jeff Hunter

  4. #4
    Join Date
    Feb 2003
    Location
    New York
    Posts
    75
    How about
    create a sequence SEQ
    and do insert
    insert into table (sequenceid) values(seq.nextval);
    Still learning

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