Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Pulling data based on date time returns error

Reply
Thread Tools

Pulling data based on date time returns error

 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      08-16-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Data is stored in MySQL as '2006-07-14 13:44:13'
>
> Select Result from DataListing where
> InputDate = "2006-07-14 13:44:13"
> having count(*) > 1;
>
> DBD::mysql::st execute failed: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near '"Select Result from DataListing where
> InputDate = "2006-07-14 13:' at line 1 at
> copiesinDATA.pl line 29.


It would seem that your Perl quoting and your mysql quoting are somehow
interfering with each other. As you haven't shown us any Perl, there
isn't much we can do for you.

BTW, using placeholders/bind variables often minimizes these quoting
problems.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
 
devon_banks@comcast.net
Guest
Posts: n/a
 
      08-16-2006
Data is stored in MySQL as '2006-07-14 13:44:13'

Select Result from DataListing where
InputDate = "2006-07-14 13:44:13"
having count(*) > 1;

DBD::mysql::st execute failed: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '"Select Result from DataListing where
InputDate = "2006-07-14 13:' at line 1 at
copiesinDATA.pl line 29.

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      08-16-2006
(E-Mail Removed) wrote:
> Data is stored in MySQL as '2006-07-14 13:44:13'
>
> Select Result from DataListing where
> InputDate = "2006-07-14 13:44:13"
> having count(*) > 1;
>
> DBD::mysql::st execute failed: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near '"Select Result from DataListing where
> InputDate = "2006-07-14 13:' at line 1 at
> copiesinDATA.pl line 29.


What exactly is your Perl question? You have an SQL syntax error.
Take that SQL statement and use it in MySQL's native interphase. What
results do you get?

Paul Lalli

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      08-16-2006
(E-Mail Removed) wrote:

> Data is stored in MySQL as '2006-07-14 13:44:13'
>
> Select Result from DataListing where
> InputDate = "2006-07-14 13:44:13"
> having count(*) > 1;
>
> DBD::mysql::st execute failed: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near '"Select Result from DataListing where
> InputDate = "2006-07-14 13:' at line 1 at
> copiesinDATA.pl line 29.


I would guess that you have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax.

BTW, this has nothing to do with Perl.

Random short in the dark: standard SQL uses single not double quotes.

Random short in the dark: Your "having" clause looks odd. There's no
"group by".

 
Reply With Quote
 
devon_banks@comcast.net
Guest
Posts: n/a
 
      08-16-2006

(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > Data is stored in MySQL as '2006-07-14 13:44:13'
> >
> > Select Result from DataListing where
> > InputDate = "2006-07-14 13:44:13"
> > having count(*) > 1;
> >

This should have been:
Select Result,count(*) from DataListing where
InputDate = "2006-07-14 13:44:13"
group by Result
having count(*) > 1;
I finally fixed the problem
by putting
$SQL = "Select Result,count(*) from DataListing where
InputDate = "2006-07-14 13:44:13"
group by Result
having count(*) > 1";

my $sth = $dbh->prepare(qq{$SQL});
$sth->execute ();

instead of

my $sth = $dbh->prepare(qq{"Select Result,count(*) from DataListing
where
InputDate = "2006-07-14 13:44:13"
group by Result
having count(*) > 1"});
$sth->execute ();


> > DBD::mysql::st execute failed: You have an error in your SQL syntax;
> > check the manual that corresponds to your MySQL server version for the
> > right syntax to use near '"Select Result from DataListing where
> > InputDate = "2006-07-14 13:' at line 1 at
> > copiesinDATA.pl line 29.

>
> It would seem that your Perl quoting and your mysql quoting are somehow
> interfering with each other. As you haven't shown us any Perl, there
> isn't much we can do for you.
>
> BTW, using placeholders/bind variables often minimizes these quoting
> problems.
>
> Xho
>
> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service $9.95/Month 30GB


 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      08-17-2006
(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
>> (E-Mail Removed) wrote:
>>> Data is stored in MySQL as '2006-07-14 13:44:13'
>>>
>>> Select Result from DataListing where
>>> InputDate = "2006-07-14 13:44:13"
>>> having count(*) > 1;
>>>

> This should have been:
> Select Result,count(*) from DataListing where
> InputDate = "2006-07-14 13:44:13"
> group by Result
> having count(*) > 1;
> I finally fixed the problem
> by putting
> $SQL = "Select Result,count(*) from DataListing where
> InputDate = "2006-07-14 13:44:13"
> group by Result
> having count(*) > 1";



Really?? That doesn't even compile.

my $SQL = q {
Select Result,count(*)
from DataListing
where InputDate = "2006-07-14 13:44:13"
group by Result
having count(*) > 1
};

You'd be much better off using placeholders. e.g.

my $date = '2006-07-14 13:44:13';
my $SQL = q {
Select Result,count(*)
from DataListing
where InputDate = ?
group by Result
having count(*) > 1
};

my $sth = $dbh->prepare( $SQL );
$sth->execute( $date );
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt: Pulling Abstract Item Data from Mime Data using Drag and Drop. Mudcat Python 2 12-14-2008 02:45 AM
Conditionally format Date/Time Values based on Time dch3 ASP .Net 2 11-09-2008 04:03 AM
Pulling from Access Query, Cannot Change Date/Time Formats Jim in Arizona ASP .Net 3 09-05-2006 10:00 PM
Pulling Files From a Web Site based on the URL path. ASP .Net 4 02-06-2006 02:51 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments