If You use do() with placeholers / bind variables, You have to put a 'undef' between the SQL-statement and the variable list. This gap is reserved for a poiter to an argument hash (which is very seldom used). You see this in the second example of the DBD::Mysql-documentation.

Greetings

Robert

---

Jannis Kafkoulas schrieb:
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
"






Reply via email to