Discussion:
unknown
1970-01-01 00:00:00 UTC
Permalink
<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:12pt"><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;">Hi,</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">While trying to generate an continuous sequence values for non-auto_increment column in mysql, the soci is failing with exception "Column count doesn't match value count", but same sql statements work fine from mysql command prompt.</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent;
font-style: normal;">Here is the small test code to reproduce the error:</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">---clip--</div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">#include &lt;soci/soci.h&gt;</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">#include &lt;soci/mysql/soci-mysql.h&gt;</font></div><div style="background-color: transparent;"><span style="font-family: tahoma, 'new york', times, serif; background-color: transparent;">main() {</span><br></div><div style="background-color: transparent;"><span style="font-family: tahoma, 'new york', times, serif; background-color:
transparent;">&nbsp; &nbsp; soci::session sql("mysql","service=dbrepl user=scott password=tiger" );</span><br></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " CREATE TABLE a ( a_c1 int, a_c2 int)";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; "CREATE TABLE b (b_c1 int)";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " INSERT INTO b values &nbsp;(10)";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " INSERT INTO b values (20)";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " INSERT INTO b values (30)";</font></div><div style="background-color: transparent;"><font
face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " &nbsp;SELECT @row := 0";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">&nbsp; &nbsp; sql &lt;&lt; " INSERT INTO a(a_c1,a_c2) SELECT @row := @row+1 as a_c1, b_c1 as a_c2 &nbsp;from b ";</font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif"><br></font></div><div style="background-color: transparent;"><font face="tahoma, new york, times, serif">}</font></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;">---clap--</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;">On running this, I get error as below:</div><div style="font-family: tahoma, 'new york', times,
serif; font-size: 12pt;">---</div><div><div><font face="tahoma, new york, times, serif">[***@SRadiusDEV tmp]$ ./a.out</font></div><div><font face="tahoma, new york, times, serif">terminate called after throwing an instance of 'soci::mysql_soci_error'</font></div><div><font face="tahoma, new york, times, serif">&nbsp; what(): &nbsp;Column count doesn't match value count at row 1</font></div><div><font face="tahoma, new york, times, serif">Aborted</font></div><div><font face="tahoma, new york, times, serif">[***@SRadiusDEV tmp]$</font></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;">---clap-</div></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 12pt;">
Loading...