Hello,
Hopefully this is the right place to post my question.
I'm trying to create a dynamic query by populating a select statement from an array. The code below is one fetchrow_array problem away from working. Unfortunately, I'm googled out and can't seem to figure out why the fetchrow_array function within the while statement doesn't run.
####
foreach $match(@match) {
($tlast, $tfirst) = split (/:/, $match);
#Select last, first, and RESP of db users
$sql = qq{SELECT LAST, FIRST, RESP FROM data };
$sql .= qq{WHERE LAST="$tlast" AND FIRST="$tfirst" };
#Prep and execute SQL
$st_handle = $db_handle->prepare($sql) || die "Cannot prepare SQL";
$st_handle->execute || die "Cannot select record" . $st_handle->errstr();
($lastDB, $firstDB, $respDB) = $st_handle->fetchrow_array || warn($st_handle);
}
#####
I get the following warning:
DBI::st=HASH(0x824e578) when the fetchrow_array executes.
Anyone have additional resources I could look into?
Thanks in advance for any help.
1 3151
I think the problem was a line return at the end of each line, chomp was the fix for that. Added the '?' to the select, which helped build the dynamic query. Also, the order wasn't very good, the prepare is better placed outside the loop. There's probably a better way but hope this helps someone else...
####
#Select last, first, and RESP of db users
$sql = qq{SELECT LAST, FIRST, RESP FROM testdata };
$sql .= qq{WHERE LAST=? AND FIRST=? };
#Prep and execute SQL
$st_handle2 = $db_handle2->prepare($sql) || die "Cannot prepare SQL";
my (@row);
foreach $match(@match) {
($tlast, $tfirst) = split (/:/, $match);
chomp ($tlast, $tfirst);
$st_handle2->execute($tlast, $tfirst) || die "Cannot select record" . $st_handle2->errstr();
@row = $st_handle2->fetchrow;
print "$row[0]\t$row[1]\t$row[2]\n";
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Daniel Tonks |
last post by:
Here's the situation: I have a Perl-based forum that I wrote myself. It
currently supports user accounts, but these are stored in a flat text file
(as is everything else for that matter). I'm...
|
by: John Ntow |
last post by:
I have a binary distribution of MySQL 4.0.20 installed in
/usr/local/mysql.
Therefore, the only libmysqlclient file I have is libmysqlclient.a
(static library).
And also, Perl:DBI already...
|
by: Alex Hunsley |
last post by:
I am trying to install the DBD::mysql perl module. However, it claims I
need mysql.h:
cpan> install DBD::mysql
CPAN: Storable loaded ok
Going to read /home/alex/.cpan/Metadata
Database was...
|
by: smsabu2002 |
last post by:
Hi,
I am facing the build problem while installing the DBD-MySql perl
module (ver 2.9008) using both GCC and CC compilers in HP-UX machine.
For the Build using GCC, the compiler error is...
|
by: josie23 |
last post by:
Egad,
I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile.
But, I've been trying to...
| |
by: padawanlinuxero |
last post by:
Hello all!!!
I am learning Perl here at my work, but right now I have a problem, I was reading about DBI, which is very cool since we use a lot of old DBF tables, so I am able to get the DBF...
|
by: christianlandry |
last post by:
Hi All,
I have installed mysql on my powermac G5 (64 bits) and I installed perl DBD-mysql-4.005 and DBI-1.601 that I obtained from CPAN. The installation did not work and I kept getting error...
|
by: incd |
last post by:
Hello,
I started out learning Perl today, but strict mode is just *weird* and not usefull? Why should I use it?
What makes $Username different than the other variables?
I was wondering, why I...
|
by: bthalapathi |
last post by:
I have written a script to connect the mysql db
#!/usr/bin/perl -w
use DBI;
#definition of variables
$db="MYTEST";
$host="localhost";
$user="root";
$password="rootpass";
|
by: happyse27 |
last post by:
Hi All,
I am doing a connection to database from perl to mysql via apache. Apache is configured correctly.
Mysql username is root and password is mysql1, and database name is test.
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |