in reply to Re^8: Increment DB using Perl
in thread Increment DB using Perl

> ID is the name of the row

No, it is the name of a column which identifies the row. So you want something like

UPDATE request SET ID=$newid WHERE ID = XXX

Again, you haven't told us enough information to know what XXX is.

Replies are listed 'Best First'.
Re^10: Increment DB using Perl
by Anonymous Monk on Mar 08, 2005 at 17:13 UTC
    Sorry, there isn't any XXX value the code that I have that does the update is the one here
    $sql2 = "UPDATE request SET ID='$new_id'";

    And no primary key
      As I and others in this thread have pointed out, an UPDATE statement with no WHERE clause updates all rows in the database. If you only wnat to update some rows, you need a WHERE clause. After all this you have never explained what you actually want to do. In which situation do you want to set the ID to 0? to 50? ... And it's very unclear why on earth you are mucking with the IDs anyway. There's no point in discussing the details further unless you can explain what you want to accomplish.

      update I'm sorry if I'm being harsh. There's no sin in you not understanding this. But if you want us to help, *please* tell us what you are trying to accomplish.

      Actually, it sounds like your 'XXX' is $pointer->{"id"}.

      The problem is that you are changing that while you're updating, and it's not going to work.

      You need something like

      Update ID SET ID = (select rownum from request );

      (except that doesn't work)
      You are trying to set the id of each row to be it's rownum in the way it is selected in your original query, neh?
      --------------
      It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs