Jannis Kafkoulas wrote: > Hi, > > I have this table: > > create TABLE netobj ( > name VARCHAR(100), > type int(1), > ip_mem VARCHAR(1100), > mask VARCHAR(15) default "na", > comment VARCHAR(50) default "-", > mark int(1) default 0, > primary key(name)); > > (on a debian etch). > > After emtying the table successfully I'm trying to insert new records > just read from a file (This is working fine with DBI::Mysqlsimple). > > In the DBD::Mysql docu it says: > > # INSERT some data into 'foo'. We are using $dbh->quote() for > # quoting the name. > $dbh->do("INSERT INTO foo VALUES (1, " . $dbh->quote("Tim") . ")"); > > # Same thing, but using placeholders > $dbh->do("INSERT INTO foo VALUES (?, ?)", undef, 2, "Jochen"); > > > When I now use the statement: > > $dbh->do("insert into $objtbl values (?,?,?,?,?,?)", > $name,$type,$ip,$mask,$comment,$mark); > > in my Perl script I get the error message: > > DBI::db=HASH(0x82a6388)->do(...): attribute parameter > 'g-ef_epn-iers-ica-citrix-clients' is not a hash ref > at dbd_ldtbl.pl line 51, <OBJ> line 2. > > where "g-ef_epn-iers-ica-citrix-clients" ist the value of the $name variable. > > Why the hell is here a hash ref expected? > > I'm afraid I didn't quite understand how it realy works:-(. > > Thanks for any help > > Jannis > " > > > > >
If you read the pod for the do method it says: $rv = $dbh->do($statement, \%attr, @bind_values); and you omitted \%attr. If you have not attributes to set, pass an undef like this: $dbh->do("insert into $objtbl values (?,?,?,?,?,?)", undef, $name,$type,$ip,$mask,$comment,$mark); Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com