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

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

Replies are listed 'Best First'.
Re^11: Increment DB using Perl
by jZed (Prior) on Mar 08, 2005 at 17:16 UTC
    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.

Re^11: Increment DB using Perl
by RazorbladeBidet (Friar) on Mar 08, 2005 at 17:36 UTC
    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