Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts

    Psql query: select count results

    Below is the code. So where is the result stored? I mean the counted number of distinct acc_id.

    Thank you.

    Code:
    my $dbh = DBI->connect($dbd, $keyer, $password) ||
        die "Couldn't connect to $pretty_dbname\: $DBI::errstr";
    $cmd = qq{SELECT COUNT(distinct acc_id) FROM $table WHERE keydate<$keydate;};
    $sth = $dbh->prepare($cmd);
    $sth->execute();

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    68
    Thanks
    0
    Thanked 28 Times in 28 Posts
    You must still fetch the results like with any other column

    Code:
    $sth->execute or die $dbh->errstr;
    my ($count) = $sth->fetchrow_array();

  • Users who have thanked miller for this post:

    camaross (04-13-2011)

  • #3
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    It works!

    Thank you so much.

    Quote Originally Posted by miller View Post
    You must still fetch the results like with any other column

    Code:
    $sth->execute or die $dbh->errstr;
    my ($count) = $sth->fetchrow_array();


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •