procedure for numering records - no effect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dariusz Tomon

    procedure for numering records - no effect

    Hi

    I'm trying to add numers to "id" field in my "kadry" table. I write
    procedure to do it (as follows) but running this procedure does make
    no effect.
    Where is bug?
    best regards

    D.T.

    PROCEDURE KADRY_PROC_SEQ2
    IS
    BEGIN
    declare
    i number;
    k number;
    nazwisko varchar2(40);
    cursor cur1 IS
    select * from kadry;
    BEGIN
    k:=1;
    for c1 IN cur1
    loop
    c1.id:=k;
    k:=k+1;
    end loop;
    commit;
    end;
    END;
  • Mark C. Stock

    #2
    Re: procedure for numering records - no effect


    "Dariusz Tomon" <d.tomon@mazars .plwrote in message
    news:c7c595.040 4190210.2d53007 3@posting.googl e.com...
    | Hi
    |
    | I'm trying to add numers to "id" field in my "kadry" table. I write
    | procedure to do it (as follows) but running this procedure does make
    | no effect.
    | Where is bug?
    | best regards
    |
    | D.T.
    |
    | PROCEDURE KADRY_PROC_SEQ2
    | IS
    | BEGIN
    | declare
    | i number;
    | k number;
    | nazwisko varchar2(40);
    | cursor cur1 IS
    | select * from kadry;
    | BEGIN
    | k:=1;
    | for c1 IN cur1
    | loop
    | c1.id:=k;
    | k:=k+1;
    | end loop;
    | commit;
    | end;
    | END;


    welcome to SQL ;-)

    this code only reads the KADRY table and resets a variable in memory -- if
    you want to change a value in the database you need to use an UPDATE
    statement

    ;-{ mcs


    Comment

    • Jan

      #3
      Re: procedure for numering records - no effect

      simple SQL is enough


      UPDATE your_table
      SET id =rownum;

      COMMIT;


      d.tomon@mazars. pl (Dariusz Tomon) wrote in message news:<c7c595.04 04190210.2d5300 73@posting.goog le.com>...
      Hi
      >
      I'm trying to add numers to "id" field in my "kadry" table. I write
      procedure to do it (as follows) but running this procedure does make
      no effect.
      Where is bug?
      best regards
      >
      D.T.
      >
      PROCEDURE KADRY_PROC_SEQ2
      IS
      BEGIN
      declare
      i number;
      k number;
      nazwisko varchar2(40);
      cursor cur1 IS
      select * from kadry;
      BEGIN
      k:=1;
      for c1 IN cur1
      loop
      c1.id:=k;
      k:=k+1;
      end loop;
      commit;
      end;
      END;

      Comment

      Working...