-
#!/usr/bin/perl
-
# Here Module's are define
-
use DBI;
-
# For database Connectivity
-
my $DSN = q/dbi:ODBC:SQLSERVER/;
-
my $uid = q/ivr/;
-
my $pwd = q/ivr/;
-
-
-
my $DRIVER = "Freetds";
-
my $dbh = DBI->connect($DSN,$uid,$pwd) or die "Coudn't Connect SQL";
-
-
$fund_code=103;
-
$mobile_number='7702004546';
-
$city_address='Karvy Computershare Private Limited,2E / 23, Jhandewalan Extn New Delhi - 110055';
-
-
$sql_query4 = "INSERT INTO [192.168.14.28].CommunicationLog.dbo.sms_processedfeeds (pf_Fund,pf_trtype,pf_acno,pf_ihno,pf_Mobile,pf_msgtrtype,pf_msg,pf_entdt ) VALUES (?,?,?,?,?,?,Getdate())";
-
$sql_sms = $dbh->prepare($sql_query4);
-
$sql_sms->execute($fund_code,'CALL', 0, undef, $mobile_number, 'CALL',$city_address,);
-
-
whenever i'm executing the code, i have gotten following error:
Can't call method "execute" on an undefined value at M_CHECK_SMS_STDCODE.pl line 19
2 2847 RonB 589
Expert Mod 512MB
First problem, which is the most important, is that you didn't enable strictures and warnings. You enable them by adding the strict and warnings pragmas to the beginning of EVERY script you write. - #!/usr/bin/perl
-
-
use strict;
-
use warnings;
-
use Carp; # not actually required, but is one of my preferences.
-
The next problem, unrelated to your error, is your improper use of indentation and lack of proper use of horizontal/vertical white space.
The cause of your error is that the prepare statement failed, but due to the lack of error checking, you implicitly told perl not tell you that it failed.
Here's an adjusted version which should shed some light on the reason it failed. -
#!/usr/bin/perl
-
-
use strict;
-
use warnings;
-
use Carp;
-
use DBI;
-
-
my $DSN = q/dbi:ODBC:SQLSERVER/;
-
my $uid = q/ivr/;
-
my $pwd = q/ivr/;
-
my $DRIVER = "Freetds";
-
my $dbh = DBI->connect($DSN,$uid,$pwd, { RaiseError => 1 }) # enables error checking on all db calls
-
or croak "Coudn't Connect SQL " . $DBI::errstr;
-
-
my $fund_code = 103;
-
my $mobile_number = '7702004546';
-
my $city_address = 'Karvy Computershare Private Limited,2E / 23, Jhandewalan Extn New Delhi - 110055';
-
-
my $sql_query4 = "INSERT INTO [192.168.14.28].CommunicationLog.dbo.sms_processedfeeds (pf_Fund,
-
pf_trtype,
-
pf_acno,
-
pf_ihno,
-
pf_Mobile,
-
pf_msgtrtype,
-
pf_msg,pf_entdt)
-
VALUES (?,?,?,?,?,?,Getdate())";
-
-
my $sql_sms = $dbh->prepare($sql_query4);
-
-
$sql_sms->execute($fund_code,'CALL', 0, undef, $mobile_number, 'CALL',$city_address,);
Also, I just noticed that in the execute() function, you are providing 7 values, but the "VALUES" portion of your query only has 6 "?" characters. I am not sure if that matters, but it may.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sandman |
last post by:
The subject says it all. I am doing a:
I have a perl script in which I am using a ReadParse routine that parses the
$ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed...
|
by: george |
last post by:
This is like the bug from hell. It is kind of hard to explain, so
please bear with me.
Background Info: SQL Server 7.0, on an NT box, Active Server pages
with Javascript, using ADO objects.
...
|
by: lilush |
last post by:
Hello,
i have a project where every time i want to add or update
something in the DB i use the datatable and dataadpter
and i build an insert sql command or an update sql
command to the...
|
by: Michael |
last post by:
Question. Is it possible to run Server.execute command inside global.asa
file. if it is where. Inside Application onstart? Another ideas appreciated.
Michael
|
by: skyy |
last post by:
Hi i am trying to use the system() command to run some linux command using perl script...
Eg.. Deleting files.
system("rm $filename");
However, when my $filename contain " character, the...
|
by: jram01 |
last post by:
Hi Folks,
I am facing problem to to execute .sql command in sql prompt using perl script. I am able to connect sql promt using "
my $odbcinput = "odbcinput.txt";
my...
|
by: fungazid |
last post by:
Hello guys,
I have a Perl script that calls other Perl scripts:
### Main script: ###
my @command;
$command="step1.pl";
$command="step2.pl";
|
by: jagjot |
last post by:
hey
Can anybody tell me How to convert my perl scripts in binary executables?
Which command should I make use of?
Please revert back as soon as possible and if possible drop me a mail at ...
|
by: syminder |
last post by:
Hi guy,
I using the batch program to trigger specific main class in JAR. It is simplest JAVA -cp %classpath% Main_class cmd instruction.
Initialy the jdk is not installing cause JAVA command...
|
by: lilly07 |
last post by:
I am trying to use a shell grep command inside a perl script using system command as below.
system "cat $source_path/s_${i}_${j}_0*testing.txt | grep ' $1' | head > $path/s_${i}_${j}.txt";...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |