<?xml version="1.0" encoding="windows-1252"?>
<node id="491512" title="Re^2: Accessing MS-Access memofield via DBI" created="2005-09-13 04:10:28" updated="2005-09-13 00:10:28">
<type id="11">
note</type>
<author id="332253">
reneeb</author>
<data>
<field name="doctext">
Can I do the binding dynamically depending on the datatype of the field??
&lt;br /&gt;&lt;br /&gt;
I tried&lt;br /&gt;
&lt;code&gt;
#! /usr/bin/perl

use strict;
use warnings;
use DBI ':sql_types';

my $dbh = DBI-&gt;connect('DBI:ODBC:driver=Microsoft Access-Treiber (*.mdb);dbq=db1.mdb',user,pass);

my $col = 'Testcol';

my $statement = "INSERT INTO table (`$col`) VALUES(?)";

my $coltype = get_type($col,$dbh);
$coltype = 'SQL_'.$coltype;
my $sth = $dbh-&gt;prepare($statement);

for(2..1000){
  my $var = &lt;STDIN&gt;;
  chomp $var;
  $sth-&gt;bind_param(1,$var,$coltype);
  $sth-&gt;execute($var) or die $dbh-&gt;errstr();
}

sub get_type{
  my ($name,$dbh)  = @_;
  my ($sthcolinfo) = $dbh-&gt;column_info(undef,undef,undef,$name);
  my $hashref = $sthcolinfo-&gt;fetchrow_hashref();
  return $hashref-&gt;{TYPE_NAME};
}&lt;/code&gt;
&lt;br /&gt;&lt;br /&gt;
But I got the following errormessage:&lt;br /&gt;
&lt;code&gt;DBI::st=HASH(0x3e9c2dc)-&gt;bind_param(...): attribute parameter 'SQL_INTEGER' is not a hash ref at C:/access.pl line 19&lt;/code&gt;</field>
<field name="root_node">
491231</field>
<field name="parent_node">
491253</field>
</data>
</node>
