develooper Front page | perl.dbi.users | Postings from November 2022

Table Value Parameter for SQL server

Thread Next
Rich Duzenbury
November 5, 2022 17:10
Table Value Parameter for SQL server
Message ID:
Hi All,

I am attempting to bulk merge a lot of rows quickly to an mssql server and
I understand that table value parameters are a possible option for doing so.

I set up the following test objects on the sql server (modeled after a
python example of sorts from

create table testtable (
  id int not null,
  primary key clustered (id asc)

create type dbo.testtype as table (
  id int not null,
  primary key clustered (id asc)

create procedure dbo.testproc(@tvp dbo.testtype READONLY)
as begin
  set nocount on;
  insert into testtable (id)
  select id from @tvp

And am attempting to use the following script (name tvf):


use DBI;

our $userid;
our $password;
our $dsn;

do( './tvf.conf' );

my $dbh = DBI->connect( $dsn, $userid, $password, { RaiseError => 1 });

my $sth = $dbh->prepare( qq{ exec dbo.testproc ? } );

my $table_values = [

$sth->execute( $table_values );

And I receive the following error:
Cannot bind a plain reference at ./tvf line 20.

I believe that error comes from the odbc driver and am uncertain what, if
anything, can be done about it.

My DSN starts with "dbi:ODBC:DRIVER=tds;database=" which I believe means
that this driver is used:

Has anyone had success in passing a tvf from perl via DBI?  Could anyone
share an example, please?

Thank you.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About