Perl Dbi和存储过程 [英] Perl Dbi and stored procedures

查看:164
本文介绍了Perl Dbi和存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过对SQL Server使用perl和dbi来检索存储过程的返回值?
可以有人提供示例。

How can i retrive the return value of stored procedure by using perl and the dbi against sql server ? could someone provide example.

推荐答案

DBD :: ODBC t / dir中有示例(请参见20SqlServer.t )。基本上,您可以这样做(不是一个完整的示例):

There are examples in DBD::ODBC t/ dir (see 20SqlServer.t). Basically you do (not a full working example):

my $output;
my $input = 'fred';
my $sth = $dbh->prepare(q/{ ? = call myproc(?) }/);
$sth->bind_param_inout(1, \$output, 100);
$sth->bind_param(2, $input);
$sth->execute 

现在$ output应该包含您返回的任何程序。确保在bind_param_inout中设置了足够的长度(上面的100)。

Now $output should contain whatever your procedure returned. Make sure you set then length in bind_param_inout sufficiently (the 100 above).

这篇关于Perl Dbi和存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆