Doing a very simple SELECT query and I'm not sure whats going wrong. It works fine when I do the WHERE statement pointing at one of the columns other than the primary key (weight). But as soon as I try and do a SELECT on the primary key the query hangs. Also this SELECT query works fine from the MySQL Administration program but always hangs through perl.
my $query_submitted = "SELECT * FROM rates WHERE weight = 2"; # Hangs
my $query_submitted = "SELECT * FROM rates WHERE zone2 = '4.67'"; # Wo
+rks fine
Here is the table information from a
"DESCRIBE rates";
| Field |
Type |
Null |
Key |
Default |
Extra |
| weight |
int(11) |
NO |
PRI |
|
auto_increment |
| zone2 |
varchar(45) |
NO |
|
|
|
I've tried using placeholders, placing quotes around the number, leaving quotes out. It always seems to just hang. Any thoughts on what I'm missing here?
my $weight = 4;
my $query_submitted = 'SELECT * FROM rates WHERE weight = ?';
# This executes the query
my $sth_submitted = $dbh->prepare($query_submitted) or die "Error prep
+are";
$sth_submitted->execute($weight) or die 'Error';
Any help is appreciated. As always, thank you in advance.
EDIT: This is also on a Windows Server 2003 box. FYI.
UPDATE: Gave up. Switched to an ODBC connection and it works like intended...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.