当我想在数据库的表中插入记录时,出现以下错误消息:insert语句中的列少于values子句中指定的列。这是我的SQL语句:
dm.qr_emp.SQl.Add( 'insert into emp_per(nom, prenom, date_naiss1, cle_ccp,nomf,prenomf,' +
'lieu_naiss,sex,adr,id_corps,id_fonction,id_categ,montant_resp,' + 'compte_ccp,etat,sal_base,id_grade,id_banque,id_degree,sal_unique,' +'pfc,iep,num_social,sal_principale,ind,salaire,montant_irg,' +
'ss,nbr_enfant,nbr_enfant_sup,bource_f,irg,retenue) '
);
dm.qr_emp.SQL.Add
('values('+quotedstr(edit1.Text)+', '+quotedstr(edit2.Text)+','+quotedstr(formatdatetime('yyyy-dd-mm',datetimepicker1.DateTime))+', '+
edit4.Text+','+quotedstr(edit5.Text)+','+quotedstr(edit3.Text)+','+quotedstr(edit6.Text)+','+quotedstr(ComboBox3.Text)+','+quotedstr(edit8.Text)+','+ inttostr(id_corps)+','+ inttostr(id_fonction)+',
'+quotedstr(edit10.Text)+','+floattostr(salair_responsabilite)+','+quotedstr(edit7.Text)+','+quotedstr(ComboBox5.Text)+','+floattostr(salaire_base)+','+ inttostr(id_grade)+','+ inttostr(id_banque)+','+
inttostr(id_degree)+','+quotedstr(ComboBox8.Text)+','+
floattostr(pfc)+','+quotedstr(edit15.Text)+','+quotedstr(edit13.Text)+','+
floattostr(sal_principale)+','+floattostr(ind)+','+quotedstr(edit20.text)+',+'+floattostr(montant_irg)+','+floattostr(ss)+', '+(edit23.Text)+',
'+quotedstr(edit26.Text)+','+floattostr(boursef)+','+quotedstr(edit21.Text)+','+
floattostr(retenu)+')');
dm.qr_emp.ExecSQL;
答案 0 :(得分:1)
要插入记录时,列数必须与插入值的数目相同。例如:
INSERT INTO Employees(Name, City, AccountNumber)
VALUES ("John", "London", "0098737602230")
例如,下一个语句将失败,因为列名和插入值的数量不匹配。
INSERT INTO Employees(Name, City)
VALUES ("John", "London", "0098737602230")
INSERT INTO Employees(Name, City, AccountNumber)
VALUES ("John", "London")
我建议您对代码进行一些整理。当前的声明是人类无法理解的,并且会导致错误。