(Fwd) "Can't call method execute" error "undefined value"

----- Forwarded message from Luis Colon <luiscolon00@yahoo.com> -----

Date: Mon, 5 Mar 2001 07:44:29 -0800 (PST)
From: Luis Colon <luiscolon00@yahoo.com>
Subject: "Can't call method execute" error "undefined value"
To: Tim.Bunce@ig.co.uk

Please assist:
I'm trying to create an interactive HTML that will
Post data into a Perl script, parse the data, then
connect to an Oracle database and INSERT the data in a
table.

The script seems like it connects to the db, but fails
to perform the $sth->execute(); that runs the SQL
statement.

My ENV is set to the proper directory on the Unix box,
and I'm specifying use DBI; in the beginning of the
script. I'm receiving "Can't call method "execute",
undefined value /'cgi file name' line (line of the
execute statement)

Any suggestions?

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

----- End forwarded message -----
0
Tim
3/5/2001 4:30:56 PM
perl.dbi.users 11100 articles. 1 followers. Follow

7 Replies
1169 Views

Similar Articles

[PageSpeed] 36

Date sent:      	Mon, 5 Mar 2001 16:30:56 +0000
From:           	Tim Bunce <Tim.Bunce@ig.co.uk>
To:             	dbi-users@perl.org
Copies to:      	luiscolon00@yahoo.com
Subject:        	(Fwd) "Can't call method execute" error "undefined value"
Organization:   	Paul Ingram Group, Software Systems, +44 1 483 862800

> ----- Forwarded message from Luis Colon <luiscolon00@yahoo.com> -----
> 
> Date: Mon, 5 Mar 2001 07:44:29 -0800 (PST)
> From: Luis Colon <luiscolon00@yahoo.com>
> Subject: "Can't call method execute" error "undefined value"
> To: Tim.Bunce@ig.co.uk
> 
> Please assist:
> I'm trying to create an interactive HTML that will
> Post data into a Perl script, parse the data, then
> connect to an Oracle database and INSERT the data in a
> table.
> 
> The script seems like it connects to the db, but fails
> to perform the $sth->execute(); that runs the SQL
> statement.
> 
> My ENV is set to the proper directory on the Unix box,
> and I'm specifying use DBI; in the beginning of the
> script. I'm receiving "Can't call method "execute",
> undefined value /'cgi file name' line (line of the
> execute statement)
> 
> Any suggestions?

Sounds as if you forgot to

my $sth = $dbh->prepare($your_sql_statement);

before executing it. A bit more of your code would help anyways.

Bodo

eingb@uni-muenster.de

0
eingb
3/5/2001 4:40:38 PM
Luis,

On Mon, Mar 05, 2001 at 04:30:56PM +0000, Tim Bunce wrote:
> ----- Forwarded message from Luis Colon <luiscolon00@yahoo.com> -----
> 
> Date: Mon, 5 Mar 2001 07:44:29 -0800 (PST)
> From: Luis Colon <luiscolon00@yahoo.com>
> Subject: "Can't call method execute" error "undefined value"
> To: Tim.Bunce@ig.co.uk
> 
> Please assist:
> I'm trying to create an interactive HTML that will
> Post data into a Perl script, parse the data, then
> connect to an Oracle database and INSERT the data in a
> table.
> 
> The script seems like it connects to the db, but fails
> to perform the $sth->execute(); that runs the SQL
> statement.

It sounds like you forgot to check that your

$sth = $dbh->prepare($sql) 

command was successfull. prepare() and all other DBI methods return a
true value when there was no error and a false value if an error
occurred. (perldoc DBI for more info)

Try:

$sth = $dbh->prepare($sql)
  or die "Problem preparing: ", $dbh->errstr;

Also, an excerpt from your code showing the problem area would be useful
to anyone trying to help you.

hth,
-C.
0
cmeyer
3/5/2001 5:27:49 PM
Here is the code in question:

#!/usr/local/bin/perl

use DBI;
&parse;
&connect;

sub parse
{
(parses data code)
}



sub connect
{

$host = "$nameofmyserver";
$sid = "$sid";
$user = "lcolon";
$password = "time2fly";
$|=1;

BEGIN {
$ENV{ORACLE_HOME} = "/apps/oracle/product/8.1.6";
$ENV{EPC_DISABLED} = "TRUE";
}

$dbh =
DBI->connect("DBI:Oracle:host=$host;sid=$sid;port=1521",$user,
$password) or die "Can't connect:$DBI::errstr\n";

$deviationid = time();
$statement = "INSERT INTO CGTI_AR VALUES
($deviationid,$formdata{'Requestor_Name'},$formdata{'Requestor_Email'},$formdata{'Requestor_Telephone'})";

my $sth = $dbh->prepare($statement);

$sth->execute;
$sth->finish;
$dbh->disconnect;

}


--- Bodo Eing <eingb@uni-muenster.de> wrote:
> Date sent:      	Mon, 5 Mar 2001 16:30:56 +0000
> From:           	Tim Bunce <Tim.Bunce@ig.co.uk>
> To:             	dbi-users@perl.org
> Copies to:      	luiscolon00@yahoo.com
> Subject:        	(Fwd) "Can't call method execute"
> error "undefined value"
> Organization:   	Paul Ingram Group, Software
> Systems, +44 1 483 862800
> 
> > ----- Forwarded message from Luis Colon
> <luiscolon00@yahoo.com> -----
> > 
> > Date: Mon, 5 Mar 2001 07:44:29 -0800 (PST)
> > From: Luis Colon <luiscolon00@yahoo.com>
> > Subject: "Can't call method execute" error
> "undefined value"
> > To: Tim.Bunce@ig.co.uk
> > 
> > Please assist:
> > I'm trying to create an interactive HTML that will
> > Post data into a Perl script, parse the data, then
> > connect to an Oracle database and INSERT the data
> in a
> > table.
> > 
> > The script seems like it connects to the db, but
> fails
> > to perform the $sth->execute(); that runs the SQL
> > statement.
> > 
> > My ENV is set to the proper directory on the Unix
> box,
> > and I'm specifying use DBI; in the beginning of
> the
> > script. I'm receiving "Can't call method
> "execute",
> > undefined value /'cgi file name' line (line of the
> > execute statement)
> > 
> > Any suggestions?
> 
> Sounds as if you forgot to
> 
> my $sth = $dbh->prepare($your_sql_statement);
> 
> before executing it. A bit more of your code would
> help anyways.
> 
> Bodo
> 
> eingb@uni-muenster.de
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/
0
luiscolon00
3/5/2001 6:04:44 PM
Hi there.

My question is very easy.
How can i execute a Oracle Function (into ORacle package body) from perl
code (Cgi), and catch the return code after execution that Oracle function?

Ptda: excuseme for my poor english, sorry.

Thank's you very much.

0
isalis
3/5/2001 7:22:16 PM
On Mon, 5 Mar 2001, Luis Colon wrote:

> my $sth = $dbh->prepare($statement);

You need to make sure that this call is successful.  I would also use
placeholders:

$statement = qq(INSERT INTO CGTI_AR VALUES(?,?,?,?));

my $sth = $dbh->prepare($statement) or die "error preparing statement
	  $DBI::errstr\n";

$sth->execute($deviationid,$formdata{'Requestor_Name'},
	$formdata{'Requestor_Email'},$formdata{'Requestor_Telephone'});

-- Brett
				http://www.chapelperilous.net/~bmccoy/
------------------------------------------------------------------------
Kettering's Observation:
	Logic is an organized way of going wrong with confidence.



0
bmccoy
3/5/2001 7:32:48 PM
I think the problem is that the connect method failed.  Use the double
pipe  ||  version of the 'or' operator instead of the word 'or' here:

$dbh= DBI->connect("DBI:Oracle:host=$host;sid=$sid;port=1521",$user,
 $password) 
-->	|| die "Can't connect:$DBI::errstr\n";

(If you use 'or' perl is actually checking to see if the assignment to
$dbh worked, rather than whether the connect method succeeded).

You should also check the result of prepare and execute the same way for
good measure.

hope that helps!

Ian Macdonald



On Mon, 5 Mar 2001, Luis Colon wrote:

> Here is the code in question:
> 
> #!/usr/local/bin/perl
> 
> use DBI;
> &parse;
> &connect;
> 
> sub parse
> {
> (parses data code)
> }
> 
> 
> 
> sub connect
> {
> 
> $host = "$nameofmyserver";
> $sid = "$sid";
> $user = "lcolon";
> $password = "time2fly";
> $|=1;
> 
> BEGIN {
> $ENV{ORACLE_HOME} = "/apps/oracle/product/8.1.6";
> $ENV{EPC_DISABLED} = "TRUE";
> }
> 
> $dbh =
> DBI->connect("DBI:Oracle:host=$host;sid=$sid;port=1521",$user,
> $password) or die "Can't connect:$DBI::errstr\n";
> 
> $deviationid = time();
> $statement = "INSERT INTO CGTI_AR VALUES
> ($deviationid,$formdata{'Requestor_Name'},$formdata{'Requestor_Email'},$formdata{'Requestor_Telephone'})";
> 
> my $sth = $dbh->prepare($statement);
> 
> $sth->execute;
> $sth->finish;
> $dbh->disconnect;
> 
> }
> 
> 
> --- Bodo Eing <eingb@uni-muenster.de> wrote:
> > Date sent:      	Mon, 5 Mar 2001 16:30:56 +0000
> > From:           	Tim Bunce <Tim.Bunce@ig.co.uk>
> > To:             	dbi-users@perl.org
> > Copies to:      	luiscolon00@yahoo.com
> > Subject:        	(Fwd) "Can't call method execute"
> > error "undefined value"
> > Organization:   	Paul Ingram Group, Software
> > Systems, +44 1 483 862800
> > 
> > > ----- Forwarded message from Luis Colon
> > <luiscolon00@yahoo.com> -----
> > > 
> > > Date: Mon, 5 Mar 2001 07:44:29 -0800 (PST)
> > > From: Luis Colon <luiscolon00@yahoo.com>
> > > Subject: "Can't call method execute" error
> > "undefined value"
> > > To: Tim.Bunce@ig.co.uk
> > > 
> > > Please assist:
> > > I'm trying to create an interactive HTML that will
> > > Post data into a Perl script, parse the data, then
> > > connect to an Oracle database and INSERT the data
> > in a
> > > table.
> > > 
> > > The script seems like it connects to the db, but
> > fails
> > > to perform the $sth->execute(); that runs the SQL
> > > statement.
> > > 
> > > My ENV is set to the proper directory on the Unix
> > box,
> > > and I'm specifying use DBI; in the beginning of
> > the
> > > script. I'm receiving "Can't call method
> > "execute",
> > > undefined value /'cgi file name' line (line of the
> > > execute statement)
> > > 
> > > Any suggestions?
> > 
> > Sounds as if you forgot to
> > 
> > my $sth = $dbh->prepare($your_sql_statement);
> > 
> > before executing it. A bit more of your code would
> > help anyways.
> > 
> > Bodo
> > 
> > eingb@uni-muenster.de
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail. 
> http://personal.mail.yahoo.com/
> 

0
ian
3/5/2001 7:55:30 PM
The value of an assignment operation is the value assigned; in this case the
result from DBI->connect().  The 'or' version is generally preferred in this
sort of situation to be sure all operations to the left have been performed
before the 'or'.
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Ian Macdonald" <ian@mail.tsgroup.net>
To: "Luis Colon" <luiscolon00@yahoo.com>
Cc: "Bodo Eing" <eingb@uni-muenster.de>; <dbi-users@perl.org>
Sent: Monday, March 05, 2001 11:55 AM
Subject: Re: (Fwd) "Can't call method execute" error "undefined value"


> I think the problem is that the connect method failed.  Use the double
> pipe  ||  version of the 'or' operator instead of the word 'or' here:
>
> $dbh= DBI->connect("DBI:Oracle:host=$host;sid=$sid;port=1521",$user,
>  $password)
> --> || die "Can't connect:$DBI::errstr\n";
>
> (If you use 'or' perl is actually checking to see if the assignment to
> $dbh worked, rather than whether the connect method succeeded).
>
> You should also check the result of prepare and execute the same way for
> good measure.


0
mchase
3/6/2001 12:26:08 PM
Reply:

Similar Artilces:

Need libwww guru help please. "Can't call method "request" on an undefined value at ....."
Hi folks. Seriously in need of some help from the Master here. I'll enclose the little bit of sample code, and even a web address to test it out if you've a mind... I'm trying to set up an interface to a secure server to post creditcard details, and on success, return to the interface. Easy? I though so. but was wrong as usual. As a standalone program, it works fine. As a subroutine in another program, called from a webpage, it fails. ......................................... Can't call method "request" on an undefined value at /usr/local/lib/perl5/site...

LWP::UserAgent. Can't call method "request" on an undefined value at ???? what is causing this error in the cgi?
I have a test.pl program working, basically the standard example with a few extras. It works fine as a stand alone program, but fails as a subroutine in a cgi? and I can't understand why -====================== #!/usr/local/bin/perl use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("AgentName/0.1 " . $ua->agent); #create request my $req = new HTTP::Request POST => 'https://sec.aba.net.au/cgi- bin/service/authorise/test'; $req->content_type('application/x-www-form-urlencoded'); $req->content('&secParams=https://sec.aba.ne...

Can't get away from: "Could not open in Design View. Quote values differently inside a '<% ... "value" ... %>' block."
I keep getting this error message when I try to switch to design view. This is the code that is causing it. OnClick="javascript:void(0);ToggleRowDisplay(this,'row<%# DataBinder.Eval(Container.DataItem, "Equipment_ID") %>');" When I take out this section I can go into design view without a problem. Any ideas?? is the word row has to be there?mess with the best...die like the rest...

Can't locate object method "connect" via package "DBI"
------=_NextPart_000_001B_01C102EB.C7598F30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi I have upgraded my machine as following RHLinux 6,.2 --> 7.0 PostgreSql 65. --> 7.0 Perl 5 -->Perl 5.6 I have installed DBI & DBD again after the upgradation. My problem is my old perl codes (which were running perfectly before upgradation) uses connect are not running. It can't connect postgresql databse through DBI. The error is --- Can't locate objrect method "connect" via package "DBI&qu...

Can't locate objrect method "connect" via package "DBI"
Hi I have upgraded my machine as following RHLinux 6,.2 --> 7.0 PostgreSql 65. --> 7.0 Perl 5 -->Perl 5.6 I have installed DBI & DBD again after the upgradation. My problem is my old perl codes (which were running perfectly before upgradation) uses connect are not running. It can't connect postgresql databse through DBI. The error is --- Can't locate objrect method "connect" via package "DBI" I posted this letter earlier, somebody asked me wheather I used use DBI. THe answer yes, I mentioned that MY CODES WERE RUNNING PERFECTLY BEFOR...

Can't locate object method "trace_msg" via package "DBI"
Please help in order to fix the problem, I am newbie in the httpd.conf I have put the bellow lines: Alias /perl/ /usr/apache/perl5/5.005/i86pc-solaris/Apache/ PerlModule DBI When I try to run the httpd I get: Can't locate object method "trace_msg" via package "DBI" at /usr/perl5/site_perl/5.005/i86pc-solaris/DBI.pm line 341. END failed--cleanup aborted. run: Error 0 I am using the bellow software: OS: solaris 8/intel httpd: apache 1.3.20 mysql: 3.23.38-1 DBI: 1.18 (I have compiled using gcc) Thank you in advance Why do you put that in http...

Can't call method "prepare" on an undefined value
------_=_NextPart_001_01C74458.9F8FEB0A Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C74458.9F8FEB0A" Content-Transfer-Encoding: 7bit ------_=_NextPart_002_01C74458.9F8FEB0A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Hi, I have one oracle database located at server A and setup the Oracle HTTP Server at Server B. Both server are Solaris server. I have installed DBI and DBD into Server B and setup the oraperl in my perl script. When I run the perl script, I am getting error: =20 =20 Can&#...

Can't call method "request" on an undefined value at ...
Full error: Can't call method "request" on an undefined value at /usr/lib/perl5/site_perl/5.005/LWP/UserAgent.pm line 227, <DOM> chunk 69. I've got a script that does a couple thousand requests to an https URL. I get the above error sporadicly. I've had it at chunk 69, 640, 234, etc. It's seemingly random and nothing changes between runs except the location of the error. I'm new to the list but noticed, in the archive, someone having a similar (but more repeatable) problem. http://www.ics.uci.edu/pub/websoft/libwww-perl/archive...

Can't call method "FETCH" on an undefined value
Hello, I am using Net::LDAP; from within a module I didn't write myself, and get the following error at exit (everything working otherwise fine): (in cleanup) Can't call method "FETCH" on an undefined value at /usr/lib/perl5/vendor_perl/5.8.5/Net/LDAP.pm line 244 during global destruction. Is this a known problem, an error in my usage of the module, or in the intermediate module? Are there hints for me to debug this? The version of LDAP.pm I use is: $VERSION = "0.31"; $LDAP_VERSION = 3; # default LDAP protocol version The versio...

"Can't locate object method "epath" via package "URI::http""
Greetings, I've been trying to debug why I can't issue a form -> click and finally started debugging it as a standalone script (as opposed to viewing CGI output in a browser, duh) I get the following error msg when I issue the form->click ..... Can't locate object method "epath" via package "URI::http" at /usr/local/lib/perl5/site_perl/5.005/HTTP/Cookies.pm I'm using the same User Agent that I defined earlier in my script that was used to pull several pages (including the form I'm trying to submit) using cookies. My latest scrip...

Can't locate object method "connect" via package "DBI" #2
Hi I have upgraded my machine as following RHLinux 6,.2 --> 7.0 PostgreSql 65. --> 7.0 Perl 5 -->Perl 5.6 I have installed DBI & DBD again after the upgradation. My problem is my old perl codes which uses connect are not running. It can't connect postgresql databse through DBI. The error is --- Can't locate object method "connect" via package "DBI" Anshuman Das anshuman@simblos.com _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -...

Can't locate object method "connect" via package "DBI" #3
I am attempting to install a shareware library administration system called koha which is written in perl. I have used cpan to install a large number of perl modules, including DBI. But when I try to connect to DBI I always get the message in the above subject line. I wrote a very simple perl script as a test, and always get the same message: -------------------------------------------------------------------------------- use DBI; my $dsn="DBI:mysql:koha:localhost:3306"; my $user="kohaadmin"; my $pass="<whatever>"; $dbh = DBI->conne...

Can't locate object method "prepare" via package "dbh"
--------------0A8D0A4ACF1C1C1361325891 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I recently tested and installed the DBI and DBD:Oracle modules.I am a beginner to using DBI to connect to the Database. My first task is to connect to an Oracle Database using a 7.3.4 Oracle Client, with the SQL statement as "SELECT * FROM TAB" My program is as follows: #!/usr/local/bin/perl use DBI; my $dbuser = $ENV{ORACLE_USERID} || 's1_gwy/s1_gwy01'; my $dbh = DBI->connect('DBI:Oracle:', $dbuser, '') ...

HELP ME !! Can't locate object method "connect" via package "DBI"
Hi dears Excuseme, my english is very poor. My Name is Germ=E1n i live in Chile(South America), i have the followin= g problem: "can't locate object method "connect" via package "DBI". If your have the solution.... help me, please...!!! How can solution? Thanks a lot Muy atentamente, Germ=E1n Marambio Vargas= On Mon, 24 Jun 2002 11:23:51 -0400, GermanMarambio@vtr.cl wrote: >i have the following >problem: "can't locate object method "connect" via package >"DBI". Does your script even do: use ...

Web resources about - (Fwd) "Can't call method execute" error "undefined value" - perl.dbi.users

Resources last updated: 12/18/2015 11:45:10 PM