Sunday, March 27, 2011

What is wrong with this SQLite query?

I'm creating an AIR application which connects to a SQLite database. The database balks at this insert statement, and I simply cannot figure out why. There is no error, it simply does not move on.

INSERT INTO Attendee (AttendeeId,ShowCode,LastName,FirstName,Company,Address,Address2,City,State,ZipCode,Country,Phone,Fax,Email,BuyNum,PrimaryBusiness,Business,Employees,Job,Value,Volume,SpouseBusiness,DateAdded,ConstructionWorkType,UserPurchaser,DecisionMaker,SafetyProducts,NearFuturePurchase,RepContact,Winner) VALUES('39610','111111','SMITH','JIM','COMPANY','1000 ROAD STREET','','PITTSBURGH','PA','15219','','5555555555','5555555555','PERSON@EXAMPLE.NET','','','0000000000000000000','','','','','0?','Fri Jan 30 14:20:08 GMT-0500 2009','other','neither','no','gas_detection','no','no','winner')

I know that the app can connect to the database, because it creates the table just fine. Here's the schema for the table for your reference:

CREATE TABLE Attendee (AttendeeId TEXT PRIMARY KEY,ShowCode TEXT,LastName TEXT,FirstName TEXT,Company TEXT,Address TEXT,Address2 TEXT,City TEXT,State TEXT,ZipCode TEXT,Country TEXT,Phone TEXT,Fax TEXT,Email TEXT,BuyNum TEXT,PrimaryBusiness TEXT,Business TEXT,Employees TEXT,Job TEXT,Value TEXT,Volume TEXT,SpouseBusiness TEXT,DateAdded TEXT,ConstructionWorkType TEXT,UserPurchaser TEXT,DecisionMaker TEXT,SafetyProducts TEXT,NearFuturePurchase TEXT,RepContact TEXT, Winner TEXT)

There is a good chance that there is an error in the INSERT statement, because if I try to execute it on a separate Adobe Air SQLite admin program, it throws an ambiguous error (#3115).

Thanks for any insight you might have.

EDIT:

For those wondering, if I make a simple table, thus:

CREATE TABLE Attendee (AttendeeId TEXT)

And try to insert, thus:

INSERT INTO Attendee (AttendeeId) VALUES('09283A')

I still get error #3115.

From stackoverflow
  • insert into Attendee ("AttendeeId", "ShowCode", "LastName", "FirstName", "Company", "Address", "Address2", "City", "State", "ZipCode", "Country", "Phone", "Fax", "Email", "BuyNum", "PrimaryBusiness", "Business", "Employees", "Job", "Value", "Volume", "SpouseBusiness", "DateAdded", "ConstructionWorkType", "UserPurchaser", "DecisionMaker", "SafetyProducts", "NearFuturePurchase", "RepContact", "Winner") values ('39610', '111111', 'SMITH', 'JIM', 'COMPANY', '1000 ROAD STREET', '', 'PITTSBURGH', 'PA', '15219', '', '5555555555', '5555555555', 'PERSON@EXAMPLE.NET', '', '', '0000000000000000000', '', '', '', '', '0?', 'Fri Jan 30 14:20:08 GMT-0500 2009', 'other', 'neither', 'no', 'gas_detection', 'no', 'no', 'winner');
    

    Try this one, it was computer generated.

    : If I put double quotes around the values, also, then this works.
  • Have you tried running smaller statements? Like, a really simple INSERT on a really simple table?

    Have you tried quoting the column names? Maybe one of them is a reserved word.

    : If I make a simple table, thus: CREATE TABLE Attendee (AttendeeId TEXT) And try to insert, thus: INSERT INTO Attendee (AttendeeID) VALUES('09283A') I still get error #3115.
    : Sorry, in the INSERT statement, I did spell AttendeeId with the same case as it was in the CREATE TABLE statement on the "Id" portion.
  • Apparently you need to use double quotes rather than single quotes.

0 comments:

Post a Comment