Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

DBI: Insert into composite key columns

by diyaz (Beadle)
on Jan 27, 2016 at 19:19 UTC ( [id://1153775]=perlquestion: print w/replies, xml ) Need Help??

diyaz has asked for the wisdom of the Perl Monks concerning the following question:

Maybe this is a very simple error, but I can't seem to insert into a primary composite key of two columns: Chr and Pos.
$dbh->do(qq(INSERT INTO Position(Chr,Pos) VALUES(?,?)), undef, $chr, $pos);

I keep getting a mySQL syntax error, but this exact syntax works in all my other id columns so the only difference I can is this one is a composite key. When I insert row in HeidiSQL it works with the same syntax it seems.
Message: DBD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Position(Chr,Pos) VALUES('X','123456')' at line 1

Replies are listed 'Best First'.
Re: DBI: Insert into composite key columns
by poj (Abbot) on Jan 27, 2016 at 19:56 UTC
    Position (Chr,Pos)

    Add space after Position. Position is not a good name for a table as POSITION() is a function in MySQL

    poj
      !!!! oh man thank you! it works! Did not realize that.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found