UPDATE statement through perl

Поиск
Список
Период
Сортировка
От Devinder K Rajput
Тема UPDATE statement through perl
Дата
Msg-id OFC968B16A.14B13EBD-ON86256C29.00721A3D@ipaper.com
обсуждение исходный текст
Список pgsql-novice
Hi,
     I am trying to do an UPDATE via a perl script to multiple records.
However, the query only updates the first record and then breaks out of the
code.  How can I get it to update the rest of the records.  Please help.
Here is the code:

$result = $conn->exec("SELECT prime_vendor, \
                              number, \
                              hub_id \
                       FROM items \
                       ORDER BY prime_vendor, number, hub_id \
                      ");
if(PGRES_TUPLES_OK ne $result->resultStatus){
    print "Could not execute SELECT statement.\n";
    print "Error: ", $conn->errorMessage;
    print "Exiting...\n";
    exit(-1);
}

while(@row=$result->fetchrow){
    $group=2;
    $result = $conn->exec("UPDATE items
                           SET vendor_group = " . $group . " \
                           WHERE prime_vendor = '" . $row[PRIME_VENDOR] .
"' \
                             and number       = '" . $row[ITEM_NUMBER] . "'
\
                             and hub_id       =  " . $row[HUB_ID] . " \
                          ");
}

The actual processing is little bit more complex, but essentially it
assigns the variable $group to the vendor_group field.  The UPDATE query is
the part that is not working.

Devinder Rajput
Stores Division Corporate Offices
Chicago, IL
(773) 442-6474


В списке pgsql-novice по дате отправления:

Предыдущее
От: "Devinder K Rajput"
Дата:
Сообщение: UPDATE statement through perl
Следующее
От: Eric Walstad
Дата:
Сообщение: Re: formatting a date when some nulls exist