Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Just another Perl shrine
 
PerlMonks  

count of records updated

by ctaustin (Sexton)
on Jul 17, 2002 at 08:40 UTC ( [id://182404]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

ctaustin has asked for the wisdom of the Perl Monks concerning the following question:

I am using the dbi module to connect to an oracle database. The goal is to perform some updates on a couple of different tables via a webpage, when complete I would like to display the number of records that were updated for each table, much the same way that sqlplus does (i.e. 412 records updated). Is there a way to capture this value? Thanks. Tony

Replies are listed 'Best First'.
Re: count of records updated
by Cine (Friar) on Jul 17, 2002 at 08:51 UTC
    According to DBD::mysql you can use $sth->rows, not that I've ever tried... I dont know about DBD::Oracle however.

    T I M T O W T D I
Re: count of records updated
by amphiplex (Monk) on Jul 17, 2002 at 08:53 UTC
    if $sth is your executed sql statement, you can get the number of records affected via $sth->rows. (using Oracle at least)

    ---- amphiplex
Re: count of records updated
by Abigail-II (Bishop) on Jul 17, 2002 at 08:57 UTC
    If the number of rows affected is known, then for non-select actions, the execute method will return the number of affected rows. But the driver (and hence the DBI), can only do that if the database is returning this information. You can also call the method rows on the statement handle to get the result from the last execute.

    You will have to write the code to sum the results from the various executes yourself, but that shouldn't be too hard.

    Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://182404]
Approved by Sidhekin
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.