6

After I calculated several areas in the attribute table (added a column, named it "Areas" and then calculated with "$area" in the calculator), I could not save the new information within my given layer.

Instead I keep getting the below message "Could not commit changes to layer landuse "Errors: ERROR: 1 new attribute(s) not added ERROR: 55 attribute value change(s) not applied. Provider errors: SQLite error: duplicate column name: AREA SQL: ALTER TABLE "landuse" ADD COLUMN "AREA" FLOAT SQLite error: near "WHERE": syntax error SQL:"

How to deal with that?

I am very new to QGIS and have no coding background.

3
  • 2
    Does the title of this new column duplicate any existing column names?
    – Kingfisher
    Jul 10, 2017 at 21:08
  • That's what the error message says: "SQLite error: duplicate column name: AREA" a field (column) called AREA already exists in your table. Your choices are either pick a new name for your field or update the values in the existing field... in your question you mention your field should be called AREAS but it appears you're calling the field AREA so I suspect that you intended to call the field one thing but ended up forgetting the 's' on the end. Jul 10, 2017 at 21:24
  • I checked, but it did not replicate any other column. The training manual says to add a column named "AREA". However after reading your comment, I tried to add another column called "AREAS", just to see if that would be better with a new name... and that works! Not sure I fully understand why it works this time, but choosing a new name seems to do the trick. thank you! Jul 11, 2017 at 1:15

1 Answer 1

3

Field names should not interfere with reserved keywords or built-in functions.

For SQLite, you can find a list of reserved keywords here.

AREA is not on the list, but there is a SpatiaLite function AREA, see http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html#p8

Feel free to use non-English field names, or add underscores.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.