Hi,

I'm extremely new to Perl/DBI, so apologies for the dumb question. I am
wondering whether DBI returns the affected records with an insert, update oR
delete query. It appears to, but I can't access the data. See the code below

$qry = &Prepare_Query($dbh, "update tblSetup set next_val_id = next_val_id
+1");
$qry->execute() || die "error";
print "no rows = " . $qry->rows() ."\n";  #this correctly prints out the no
of rows affected
while (@data =
y->fetchrow_array){ 
print "\nsome stuff = " . $data[0] } 
*note the Prepare_Query is just the standard prepare with the SQL....

Basically the update works (in the DB) and the script prints out the correct number of 
rows that are affected, but i cant 'fetch' any info on the updated rows, as it says I 
should run an 'execute before fetch' - maybe because the rows returned by executing 
the update are 'null'. Is there any way to perform this trivial example where I 
increment a field of a row and return its value using a single prepare statement? I 
was hoping to achieve this by executing the update statement and receiving the 
affected records. 

Alternatively, is there a way to lock an entire table, so that I can do a two-step 
process , i.e. select the number, store it, increment it and then update it - but lock 
it so that any concurrency issues are avoided?

Thanks for your help.





Reply via email to