[Qgis-user] SQL Updates on virtual layer shape file attribute failes

Stephan Weiser stephan.weiser at gmx.com
Sun Jul 3 02:25:36 PDT 2016


Hey there,

I am using QGIS 2.14.1 (Essen). In order to create a city scenery for a Flight Simulator, I need to process shp-files.
The shape files I use are the shape files of open street map. For a certain city loaded the shp file into QGIS with the name „buildings“. For the Flight Simulator I have to define several „classes“ of buildings using the „type“ attribute of a single shape. As the shape file I downloaded is only poorly descripted (most „types“ are NULL), I want to overwrite the „type“ Attribute with the proper names To make it easy for you, i have the following shape files als QGIS virtual layers:

- „buildings“ (the downloaded shp file -> original layer with all Buildings)
- „buildingsTypeA“ (a subset of „Buildings“ with target „type“ „btA“)
- „buildingsTypeB“ (a subset of „Buildings“ with target „type“ „btB“)
- „buildingsTypeC“ (a subset of „Buildings“ with target „type“ „btC“)

The „buildingType“ Layers have been created by selecting the proper shapes in „Buildings“ and copying them into a new virtual layer.

As every building shape of A, B and C occur in „Buildings“ I tried to write a simple SQL update Statement like this. All the virtual layers have the same structure (osm_id, name, type, geometry)

UPDATE buildings
SET type = 'btA‘
WHERE buildings.osm_id IN (SELECT osm_id from buildingsTypeA)

The same should be done for buildingsTypeA and buildingsTypeA.

When I exectute the Statement, I get an error: „near "update": syntax error“. Simple SELECT Statements work. To simplify it further I also noticed that e.g the following query resulted in the same error

UPDATE Buildings
Set type =‘abc‘
WHERE buildings.osm_id = '12345567‘

So my questions are:

- Does the Database Manager Plugin for QGIS only Support Select Statements (Read Only)?
- If yes, is there a different way to edit the data in batch mode? (round about 5000 buildings have to be updated)
- Are there other ways to Access shp-files in a SQL-like manor to perform that UPDATE Statements?

Hope you can help me out here.

Best regards,

Stephan





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20160703/1a64b276/attachment.html>


More information about the Qgis-user mailing list