#!/usr/bin/perl
use DBI;
use strict;
use warnings;
my $db_instance = "HIPCCMGMT";
my $db_name = "CDR_CUCM7_1_5";
my $db_user = "sa";
my $db_pass = 'MyPassword';
my $dbh = DBI->connect("DBI:ODBC:Driver={SQL Server};Server=$db_instance;Database=$db_name;UID=$db_user;PWD=$db_pass")
or die("\n\nCONNECT ERROR:\n\n$DBI::errstr");
my %hash = (
1 => "A",
2 => "13"
);
my @keys = keys %hash;
my @values = values %hash;
my $sth = $dbh->prepare("INSERT INTO DevicesData(DeviceName, DataValue) VALUES (?,?);");
$sth->execute_array({},\@keys, \@values);
$dbh->disconnect;
C:\>perl test.pl
DBD::ODBC::st execute_array failed: executing 2 generated 1 errors at test.pl li
ne 23.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
http://members.toast.net/strycher/perl/example_dbi_sql.htm
http://community.activestate.com/forum-topic/how-to-activeperl-connect