I know the error where it is. And I mentioned that too.

Its from Module while executing in programm

DBD::mysql::st execute failed: You have an error in your SQL syntax; c +heck the manual that corresponds to your MySQL server version for the + right syntax to use near ''cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat5=0 +,cat6=0,cat7=0'' at line 1 at ./dnd_category_management_incremental_p +rovisioning.pl line 208, <FD> line 1.

Its from DB terminal while I executing manually

mysql> insert into user_master (msisdn,cat0,cat1,cat2,cat3,cat4,cat5,c +at6,cat7,vip,SAcode,phone_type) values (919596354636,0,1,0,0,0,0,0,0, +0,0,0)on duplicate key update 'cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat +5=0,cat6=0,cat7=0'; ERROR 1064 (42000): You have an error in your SQL syntax; check the ma +nual that corresponds to your MySQL server version for the right synt +ax to use near ''cat0=1,cat1=0,cat2=0,cat3=0,cat4=0,cat5=0,cat6=0,cat +7=0'' at line 1

If I remove the single quotes the query is executing properly.

Its very clear that when I passing argument to $sth->execute() its taking the argument and adding '' (single quotes) to the statement. If the single quotes is not there it will execute properly. Why the module adding single quotes to my query. How to make query without adding quotes

This code is working very fine

my $IP = "172.16.2.163"; my $user = "root"; my $table = "user_master"; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$IP;mysql_socket=/ +opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","$user","",{'RaiseError' + => 1}); my $user_sth = $dbh->prepare("insert into user_master (msisdn,cat0,ca +t1,cat2,cat3,cat4,cat5,cat6,cat7,vip,SAcode,phone_type) values (?,?,? +,?,?,?,?,?,?,?,?,?) on duplicate key update cat0=0"); $user_sth->execute($msisdn,@db_values,0,$SAC,$phone_type) or die $DBI: +:errstr;
CREATE TABLE `user_master` ( `msisdn` bigint(20) NOT NULL, `cat0` tinyint(1) DEFAULT '0', `cat1` tinyint(1) DEFAULT '0', `cat2` tinyint(1) DEFAULT '0', `cat3` tinyint(1) DEFAULT '0', `cat4` tinyint(1) DEFAULT '0', `cat5` tinyint(1) DEFAULT '0', `cat6` tinyint(1) DEFAULT '0', `cat7` tinyint(1) DEFAULT '0', `vip` tinyint(1) DEFAULT '0', `SAcode` bigint(10) NOT NULL DEFAULT '0', `phone_type` bigint(10) NOT NULL DEFAULT '0', PRIMARY KEY (`msisdn`), KEY `num` (`msisdn`) )

But when I use "?" after duplicate key its not working

my $IP = "172.16.2.163"; my $user = "root"; my $table = "user_master"; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$IP;mysql_socket=/ +opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","$user","",{'RaiseError' + => 1}); my $user_sth = $dbh->prepare("insert into user_master (msisdn,cat0,ca +t1,cat2,cat3,cat4,cat5,cat6,cat7,vip,SAcode,phone_type) values (?,?,? +,?,?,?,?,?,?,?,?,?) on duplicate key update ?"); $user_sth->execute($msisdn,@db_values,0,$SAC,$phone_type,$db_update_cm +d) or die $DBI::errstr;

In reply to Re^2: Error in $sth->execute() by ravi45722
in thread Error in $sth->execute() by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.