Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Binding values to table with autoincrement ID

by McA (Priest)
on Aug 27, 2014 at 17:05 UTC ( [id://1098781]=note: print w/replies, xml ) Need Help??


in reply to Binding values to table with autoincrement ID

Hi,

you have to specify what columns of the table you want to insert values into. So you have to do something like:

my $sql = "INSERT INTO table (col2, col3, col4, col5, col6, col7, col8 +) VALUES (?,?,?,?,?,?,?)";

where colX are the names of the columns to insert into. I assumed that the first column is the autoincrement column. You have to take the real column names.

Without specifying the column names I would guess that the driver is going from left to right in the column definition of the table trying to bind the first variable to the autoincrement column.

My advice: Do always specify the column names. It's more robust against some kind of table layout changes.

McA

Replies are listed 'Best First'.
Re^2: Binding values to table with autoincrement ID
by sowais (Sexton) on Aug 27, 2014 at 18:25 UTC
    Thanks McA! that did the trick!

      Also, you should realise last_insert_id will not work with DBD::ODBC - read last_insert_id

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1098781]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-23 16:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found