Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert (SQL) error 2

Status
Not open for further replies.

k2a

Programmer
Jun 26, 2012
133
DE
When executing a SQL "insert into" command with 14 fieldnames and 14 value expressions, it returns an error message "Too many arguments".

The syntax shown from help for the insert command does not indicate that there are any limits for the arguments.
INSERT INTO dbf_name [(FieldName1 [, FieldName2, ...])] VALUES (eExpression1 [, eExpression2, ...])

Are there any limits or what else could cause that error?


Regards,
Klaus
 
Klaus,

I'm not aware of a limit. If one does exist, I feel sure that it would be more than 14. I must have inserted more than that number of fields at some time, and I don't remember ever seeing this problem.

The obvious thing to check is that the number of expressions in the VALUES clause matches the number of fields that you have specified.

Check also that, if any of the epxressions are function calls, that these have the correct number of arguments.

One other thing: make sure you are not trying to insert into a field that has Integer (Autoinc) data type.

If none of the above helps, try inserting just the first field on its own, then the first two, and so on, until the error returns. That will tell you which field or expression is causing the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
The error Too many arguments can only come from having more values than fields in your sql, eg
Code:
Create Cursor curTest (field1 c(10))
insert into curTest (field1) values (1,2)
causes that error. As sure as you are you only have 14 values, as sure foxpro is you pass in more. And foxpro is right. You overlook a comma, miss a string delimiter or anything like that.

Bye, Olaf.
 
An easy mistake would be trying to insert a numeric value like 3,14. That would be counted as two values 3 and 14.

And Mike also has warned about using too many arguments in function calls. For example if you do
Code:
insert into curTest (field1) values (Str(1,2,3,4))
that also causes the same error, as the STR function only takes up to 3 parameters.

Bye, Olaf.
 
Hi,
Thank you for your quick response, with those hints it was easy to locate the fault.
The mistake was indeed the numeric value, instead of using a decimal point character a comma was use.

Regards,
Klaus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top