#!/usr/bin/perl
use strict;
use DBI;
use Data::Dumper;
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
my $extension = '8315';
my $cti = '7702009896';
my $service_id =1;
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 $sql3=(qq{
declare '@' + callnumber as int
set '@' + callnumber = $callnumber
set '@' + callnumber = (Select '@'+'@' + identity)
exec "insert into rpt_call_detail (call_start_time,call_number,call_service_id,call_step_name,call_step_type,call_step_discription) values(getdate(),'@' + callnumber,$service_id,'START',0,'CLI:' + $cli)"
});
my $call_insert1 = $dbh->prepare($sql3);
$call_insert1->execute();
如何在 Perl 脚本中设置 sql server 变量?我想将电话号码设置为@@identity 我无法成功执行上述代码。请帮助我。