467,077 Members | 1,037 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

SQL count not matching the results of perl script count

100+
Hi I am having a problme where the results of the sql count is not matching the results of the perl script sql count.

The script was working fine up till Wed last week and after that the results are different on sql and on perl and the date and times are the same, I even copy and pasted the sql query from the perl script into the sql window and got different results.

Here is part of the script where i am trying to get the count
$enter_date = " between to_date('11/22/06 15:24','mm/dd/yy hh24:mi:ss')
and to_date('11/22/06 15:30','mm/dd/yy hh24:mi:ss')";


$repoSQL = qq{

select count(*) from site s where (s.lastupdateddate) $enter_date
};

$sth1 = $repoCon->prepare($repoSQL);
$sth1->execute();

$kntr = $sth1->fetchrow_array() ;

$repoSQL = qq{

select count(*) from site s where (s.createddate) $enter_date
};

$sth2 = $repoCon->prepare($repoSQL);
$sth2->execute();

$kntr2 = $sth2->fetchrow_array() ;


print "Updated Count: $kntr \n
Created Count: $kntr2 ";
$message = "Please find the attached Site Error Report. The Site Error Report reports errors occurring in the last 15 days. \n\n
Number of records updated within the last 24 hours is: $kntr \n\n\n
Number of records created within the last 24 hours is: $kntr2";
--------------------------end--------------------------------

Hope you guys could help me out, I would really appreciate it.

Thanks
Nov 27 '06 #1
  • viewed: 4428
Share:
2 Replies
miller
Expert 1GB
Add error checking to your execute:
Expand|Select|Wrap|Line Numbers
  1. $sth1 = $repoCon->prepare($repoSQL);
  2. $sth1->execute() or die $repoCon->errstr;
  3.  
Also, your function TO_DATE does not appear to exist in the latest version of MySQL.

Maybe you need the STR_TO_DATE function instead?
http://www.mysql.org/doc/refman/5.1/en/date-and-time-functions.html
Nov 28 '06 #2
100+
soory i forogt to mention this is linking to an oracle database and not mysql

Will put that error checking and see what happens thanks
Nov 28 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Xah Lee | last post: by
reply views Thread by Eric A. Hall | last post: by
4 posts views Thread by vacataire testeur de site web | last post: by
1 post views Thread by Peter v.d. Berger | last post: by
1 post views Thread by anderz1985 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.