06-12-2009
Can't call method "prepare" on an undefined value at...
I am getting the error "Can't call method "prepare" on an undefined value at..." with the following code:
<code>my %dbh;
my $dbh = DBI->connect("DBI:mysql:Customer_Data",
$username,
$password
) or die "Database connection failed.";
$myquery="SELECT * from Site";
$execute = $connect->prepare($myquery);
$execute->execute() or die $dbh->errstr;
</code>
Can anyone suggest what might be the problem?
Last edited by vincaStar; 06-12-2009 at 07:09 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link
http://www-306.ibm.com/software/data/db2/perl/
We tried to install the DBI module using
bash# perl -MCPAN -e 'install DBI'
command. However we ended up with the following error.
Stop.
... (3 Replies)
Discussion started by: jerardfjay
3 Replies
2. Programming
hi i am trying to connect to an oracle database using dbi and i get this ::
Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575
END failed--call queue aborted.
for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies
3. Shell Programming and Scripting
Hi, i have some queries on installing the Perl DBI and the DBD Oracle.
I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI
Perl Makefile.PL
make
make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies
4. Shell Programming and Scripting
Hi,
I want to connect perl with the mysql to select and so on but the connection don't work
code
#!/usr/bin/perl
BEGIN {
# PERL MODULES WE WILL BE USING
use DBI;
$dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;}
#... (1 Reply)
Discussion started by: eng_shimaa
1 Replies
5. Solaris
how dow you complie perl module DBI with mysql from /usr/local/mysql/bin
keeps going to mysql client for /usr/sfw/bin
is it the LD_PATH ???...:confused:
error is
# perl login.cgi
DBI connect('customers;mysql_socket=/tmp/mysql.sock:localhost','root',...) failed: Client does not... (1 Reply)
Discussion started by: photon
1 Replies
6. UNIX for Advanced & Expert Users
i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error:
Mon Apr 19 09:43:29 EDT 2010
/Library/Perl/DBD-mysql-4.011 ->
peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies
7. Shell Programming and Scripting
Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough)
$sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region });
$sth->execute;
my ($region, $sales);
# Bind Perl variables to columns:
$rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies
8. Shell Programming and Scripting
Hi All,
I installed DBI module in a non INC location and using it in my script via "use lib".
But it throw the below error at the "use DBI" step.
Please help
Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies
9. Shell Programming and Scripting
I am trying to write a script for my own use that will allow me to connect to network devices, then run a set of commands.
I start with a list of ips in a text file. Each ip is on its own line.
I start with a second file of commands. Each command on one line.
for illustration .. the cmd.txt... (2 Replies)
Discussion started by: popeye
2 Replies
10. Shell Programming and Scripting
Experts,
I've been struggling with making a Perl Oracle DBI script to work through my Apache webserver.
Mysql DBI scripts work fine, but I'm having issue's with Oracle.
The oracle script works on command line, but I'm getting an
"Internal Server Error" with apache
Sourcing the oracle... (0 Replies)
Discussion started by: timj123
0 Replies
LEARN ABOUT DEBIAN
ledgersmb::dbtest
LedgerSMB::DBTest(3pm) User Contributed Perl Documentation LedgerSMB::DBTest(3pm)
NAME
LedgerSMB::DBTest - LedgerSMB commit filter for test cases.
SYOPSIS
This module creates a DBI-like interface but ensures autocommit is off, and filters commit statements such that they don't do anything.
This can be used for making API test cases which involve DB commits safe for production environments.
USAGE
Both LedgerSMB.pm and LedgerSMB/Form.pm assign a global database handler for all database access within a script in the dbh property (for
example, $request->{dbh} or $form->{dbh}). By setting this early to a LedgerSMB::DBTest (instead of a DBI object), the tests can be made
safe.
However, there are a few limitations to be aware of. One cannot run tests through the standard request handler and use this module. Hence
this is limited to unit tests of files in the LedgerSMB, scripts, and bin directories.
Here is an example of how this could be done:
my $lsmb = LedgerSMB->new();
$lsmb->merge($testdata);
my $dbh = LedgerSMB::DBTest->connect("dbi:Pg:dbname=$company", "$username",
"$password",)
$lsmb->{dbh} = $dbh;
METHODS
connect($dsn, $user, $pass)
Connects to the database and returns a LedgerSMB::DBTest object
commit()
Tests the current transaction (issues a 'SELECT 1;' to the database). If this is successful returns 1, if not, rolls back and returns
false.
Note that this means all past tests are rolled back and this is inconsistent with normal transactional behavior.
prepare()
Returns a statement handle, via the private DBI database handle.
do()
passes this statement on to the private database handle
errstr()
passes this call on to the private database handle
err()
passes this call on to the private database handle
quote()
passes this call on to the private database handle
quote_identifier()
passes this call on to the private database handle
rollback()
passes this call on to the private database handle. Note that this will roll back all statements issues through this object.
perl v5.14.2 2010-03-02 LedgerSMB::DBTest(3pm)