I'm not able to insert the value into a SQL Server database from a Perl script in Linux
code is given below:
#!/usr/bin/perl
use strict;
use DBI;
use Data::Dumper;
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
my $fifth_param = "22";
my $first_param = "04-09-2012";
my $second_param = "04-09-2012";
my $third_param = "2002";
my $forth_param = "0123";
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";
# my $servernumber = 2;
# my ($dbname) = $dbh->selectrow_array("select DATABASE()");
eval
{
my $td = $dbh->do(q/USE CServer/);
# print "$td\n";
};
my $sql = "Insert into dbo.winast_outbound_callmaster (out_call_number,out_start_time,out_end_time,out_e xtenstion,out_CLI) values('$fifth_param','$first_param','$second_para m','$third_param','$forth_param')";
my $sth = $dbh->prepare($sql);
my $sth->execute() or die $dbh->errstr;
my $return = $sth->fetchrow();
my $agi->set_variable('result',$return);
print Dumper($return);
$sth->finish;
$dbh->disconnect;
I got this error :-
Can't call method "execute" on an undefined value at Outgoing_Call.agi line 45.