UPDATE statement through perl
| От | Devinder K Rajput |
|---|---|
| Тема | UPDATE statement through perl |
| Дата | |
| Msg-id | OF7D5B9719.5D2EE60B-ON86256C29.00733B6B@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 по дате отправления: