Page 1 of 1

SQLite insert data from variables: error unrecognized token

Posted: Tue Jun 02, 2015 12:20 pm
by chris0879
this bis my code:

Code: Select all


on mouseUp
   
   databaseConnect
    
    local tFname
put "myname" into Nome
   put "myemail" into Mail
   
    put getDatabaseID() into tDatabaseID
    
    
    put "INSERT into contact_details    (nome, email)         VALUES (' " & Nome& " '," & Mail& "');" into tSQL
       
    

    
    revExecuteSQL tDatabaseID, tSQL
   
   put the result into tRes
   if tRes is not a number then
      answer error "There was a problem saving this record: " & tRes as sheet
   end if
   
   
   
   
end mouseUp




error display: unrecognized token.

where is the error?
Thanks!

Re: SQLite insert data from variables: error unrecognized to

Posted: Tue Jun 02, 2015 1:14 pm
by dunbarx
Hi.

Which line threw the error?

Craig Newman

Re: SQLite insert data from variables: error unrecognized to

Posted: Tue Jun 02, 2015 1:28 pm
by chris0879
I can not see where it blocks the code!
This is a screenshot of the error!
thanks!

Re: SQLite insert data from variables: error unrecognized to

Posted: Tue Jun 02, 2015 1:48 pm
by chris0879
I solved:
after comma
VALUES (' " & Nome& " ',
omit
'
thanks anyway!

Re: SQLite insert data from variables: error unrecognized to

Posted: Tue Jun 02, 2015 1:50 pm
by Klaus
Hi Chris,

in cases like this always check the resulting SQL, here is what your script will produce:
...
INSERT into contact_details    (nome, email)         VALUES (' myname ',myemail');
...
Lots of SPACES***, and even missing single quotes...
No wonder this will create an error.
8)
***Will maybe not harm the funcitonality, but makes it very hard to read!


Best

Klaus