4 messages in com.mysql.lists.plusplusRe: template insert query & mysql++
FromSent OnAttachments
Mark Polsen14 Oct 2000 13:04 
Florian G. Pflug14 Oct 2000 14:35 
Don Thompson15 Oct 2000 08:20 
Don Thompson24 Oct 2000 18:53 
Subject:Re: template insert query & mysql++
From:Florian G. Pflug (fg@phlo.org)
Date:10/14/2000 02:35:03 PM
List:com.mysql.lists.plusplus

On Sat, Oct 14, 2000 at 01:05:05PM -0700, Mark Polsen wrote:

Error: Column count doesn't match value count at row 1

query << "insert into %5:table values (%0q, %1q, %2q, %3q, %4q)"; query.parse(); query.def["table"] = "testtable"; query.execute (2, 4, 6, 8, 1);

Hi

IMHO this has nothing to do with mysql++, but with the mysql sql syntax. Since you only specify the field VALUES in you query, mysql assumes you mean first_column = first_value, second_column=second_value,.....

To make this work, you have to explicity name the columns in your query, e.g

query << "insert into %5:table set col1=%0q, col2=%1q, col3=%3q,.... ;" ; ... ... ...

Of course, this makes your query less generic.

mfg, Florian Pflug