我想要一个简单的 perl 脚本/子程序来将 sql server 表读入哈希,有没有人有一个好的脚本或片段(带有'use's)可以在给定连接字符串和表名的情况下做到这一点?
这是一个模板:
sub sqltable {
my ($connStr,$table) = @_;
my ($user, $password, $host) = ($connectstr =~ m|^(.*)/(.*)@(.*)$|); # or whatever
my $dbh = DBI->connect("dbi:???:$host",$user,$password, { RaiseError => 1 }); # replace ??? with good SQL Server equivalent
$dbh-> ???; # anything good for this part? LongTruncOk? LongReadLen?
return $dbh->selectall_arrayref("select * from $table");
}