CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
Problems whit DBI Interfase

 



abelsgmx
Novice

Jun 6, 2002, 11:19 AM

Post #1 of 7 (6392 views)
Problems whit DBI Interfase Can't Post

How to do a SELECT MAX statement, I haev have problems whit this code:


Code
$dbh = DBI->connect ($dsn, $usr, $pwd, {RaiseError => 1}); 
$sth = $dbh->prepare ("
SELECT max(id_age) as id_age
FROM teachers
");
$sth->execute ;
$id_age = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;


This don't return the max value, some one know how do for this?, thanks a lot!!!
Crazy


Jean
User


Jun 13, 2002, 1:01 AM

Post #2 of 7 (6384 views)
Re: [abelsgmx] Problems whit DBI Interfase [In reply to] Can't Post

I'm not sure this is the issue here, but I'll try anyway...

fetchrow_array() returns an array and when you're assigning its value to a scalar, you get the number of elements of the array. You probably want to use

$id_age = ($sth->fetchrow_array);

This way you'll get the first element of the array into $id_age.

Hope this helps...


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


abelsgmx
Novice

Jul 18, 2002, 7:00 PM

Post #3 of 7 (6365 views)
Re: [Jean] Problems whit DBI Interfase [In reply to] Can't Post

Thanks a lot, this was so helpull!!!


Jean
User


Jul 20, 2002, 10:58 PM

Post #4 of 7 (6354 views)
Re: [abelsgmx] Problems whit DBI Interfase [In reply to] Can't Post

I'm glad it was Wink


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


Paul
Enthusiast

Jul 22, 2002, 3:36 AM

Post #5 of 7 (6351 views)
Re: [Jean] Problems whit DBI Interfase [In reply to] Can't Post

Or:

my ($id_age) = $sth->fetchrow;


Jean
User


Jul 22, 2002, 3:41 AM

Post #6 of 7 (6349 views)
Re: [RedRum] Problems whit DBI Interfase [In reply to] Can't Post

Cool Cool Cool


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


abelsgmx
Novice

Jul 23, 2002, 5:52 PM

Post #7 of 7 (6339 views)
Re: [Jean] Problems whit DBI Interfase [In reply to] Can't Post

Thanks a lot!!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives