DBD :: mysql 是否实现 bind_param_inout 方法? 我在尝试时收到以下错误消息:
DBD :: mysql :: st bind_param_inout 失败:输出参数不是 实现[for Statement“调用 spCreateTransactionRecord(?,?)“with ParamValues:0 = Null!,1 = Null!] at ./db.pl第23行
我的代码:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBI qw(:sql_types);
use Data::Dumper;
my ($dbh, $dsn, $sth, $sql);
my ($RecID, TypeID);
my ($user, $pass) = '';
# Open DB connection
$dsn = "dbi:mysql:database=mp;mysql_read_default_file=$ENV{HOME}/.my.cnf";
$dbh = DBI->connect($dsn, $user, $pass,
{RaiseError=>1, AutoCommit=>0, ShowErrorStatement=>1})
|| die "DB open error: $DBI::errstr";
# Call stored procedure
$sql = "call spCreateTransactionRecord(?, ?)";
$sth = $dbh->prepare($sql);
$sth->bind_param_inout(2, \$p_RecID, 11, {TYPE=>SQL_INTEGER});
$sth->execute($p_TypeID) || print $sth->errstr;
# Disconnects
$dbh->commit();
$dbh->disconnect;
存储过程声明为:
CREATE PROCEDURE spCreateTransactionRecord (
IN p_TypeID INTEGER,
OUT p_RecID INTEGER
)
答案 0 :(得分:4)
新代码的解决方法:
# Call stored procedure
$sql = "call spCreateTransactionRecord($p_TypeID, \@rtnVal)";
$dbh->do($sql);
$p_RecID = $dbh->selectrow_array('SELECT @rtnVal');
print "Received RecID = $p_RecID\n";
不合适(两个数据库调用而不是一个)但是完成了工作。
答案 1 :(得分:2)
这是一个已知的“已验证”状态的错误,这意味着它永远无法解决。
http://bugs.mysql.com/bug.php?id=23554
该错误报告还包含可能的解决方法。
单独确认问题仍未得到解决,the source code for the current (4.017) version仍有错误:
if (is_inout)
{
do_error(sth, JW_ERR_NOT_IMPLEMENTED, "Output parameters not implemented", NULL);
return FALSE;
}