SQLite UPDATE record syntax in Poco

443 Views Asked by At

I can't get the syntax here; are there some more extensive examples for POCO-SQLite ?

I am getting a Poco::exception, sendErrorResponse HTTP_INTERNAL_SERVER_ERROR

                    Poco::Data::SQLite::Connector::registerConnector();
                    // create a new session
                    Session updsession("SQLite", managers);
                    facilities UnitFacility;

                    Statement updateRecord(updsession);

                    updsession << "UPDATE facilities SET name = nameString, address = addressString, phone = phoneString WHERE facilityNumber = 3;";
                    updateRecord.execute();

//Updated: Simplified With or without [] still no go.

                    Poco::Data::SQLite::Connector::registerConnector();
                    Session updsession("SQLite", managers);
                    Statement updateRecord(updsession);
                    updsession << "UPDATE facilities SET Name = 'Frank' WHERE [FacilityNumber = 1];",now;
                    updateRecord.execute();
1

There are 1 best solutions below

3
On

Both SQL queries are invalid.

Original Query:

UPDATE facilities SET name = nameString, address = addressString, phone = phoneString WHERE facilityNumber = 3

Result:

no such column: nameString: UPDATE facilities SET name = nameString, address = addressString, phone = phoneString WHERE facilityNumber = 3

Fixed query:

UPDATE facilities SET name = 'nameString', address = 'addressString', phone = 'phoneString' WHERE facilityNumber = 3

Result:

Query executed successfully: UPDATE facilities SET name = 'nameString', address = 'addressString', phone = 'phoneString' WHERE facilityNumber = 3 (took 0ms, 1 rows affected)

Original query:

UPDATE facilities SET Name = 'Frank' WHERE [FacilityNumber = 1]

Result:

no such column: FacilityNumber = 1: UPDATE facilities SET Name = 'Frank' WHERE [FacilityNumber = 1]

Fixed query:

UPDATE facilities SET Name = 'Frank' WHERE FacilityNumber = 1

Result:

Query executed successfully: UPDATE facilities SET Name = 'Frank' WHERE FacilityNumber = 1 (took 0ms, 1 rows affected)

It is not clear what does this question have to do with HTTP.