<div dir="ltr"><div><div>Hi<br></div>Stephan, why not use the Field Calculator (with a Case When statement or an expression-based selection beforehand)?<br><br></div>Harrissou<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-07-03 11:25 GMT+02:00 Stephan Weiser <span dir="ltr"><<a href="mailto:stephan.weiser@gmx.com" target="_blank">stephan.weiser@gmx.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="DE"><div><p class="MsoNormal">Hey there,</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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.</p><p class="MsoNormal">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:</p><p class="MsoNormal"><u></u> <u></u></p><p><u></u><span>-<span style="font:7.0pt "Times New Roman"">        </span></span><u></u>„buildings“ (the downloaded shp file -> original layer with all Buildings)</p><p><u></u><span>-<span style="font:7.0pt "Times New Roman"">        </span></span><u></u>„buildingsTypeA“ (a subset of „Buildings“ with target „type“ „btA“)</p><p><u></u><span>-<span style="font:7.0pt "Times New Roman"">        </span></span><u></u>„buildingsTypeB“ (a subset of „Buildings“ with target „type“ „btB“)</p><p><u></u><span>-<span style="font:7.0pt "Times New Roman"">        </span></span><u></u>„buildingsTypeC“ (a subset of „Buildings“ with target „type“ „btC“)</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The „buildingType“ Layers have been created by selecting the proper shapes in „Buildings“ and copying them into a new virtual layer.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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)</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">UPDATE buildings</p><p class="MsoNormal">SET type = 'btA‘</p><p class="MsoNormal">WHERE buildings.osm_id IN (SELECT osm_id from buildingsTypeA)</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The same should be done for buildingsTypeA and buildingsTypeA.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">When I exectute the Statement, I get an error: „<span style="font-family:"Courier New,courier",serif">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<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New,courier",serif"><u></u> <u></u></span></p><p class="MsoNormal">UPDATE <span style="font-family:"Courier New,courier",serif">Buildings<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New,courier",serif">Set type =‘abc‘<u></u><u></u></span></p><p class="MsoNormal">WHERE buildings.osm_id = '12345567‘<span style="font-family:"Courier New,courier",serif"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New,courier",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New,courier",serif">So my questions are:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Courier New,courier",serif"><u></u> <u></u></span></p><p><u></u><span style="line-height:105%"><span>-<span style="font:7.0pt "Times New Roman"">        </span></span></span><u></u><span style="font-family:"Courier New,courier",serif">Does the Database Manager Plugin for QGIS only Support Select Statements (Read Only)?</span><span style="line-height:105%"><u></u><u></u></span></p><p><u></u><span style="line-height:105%"><span>-<span style="font:7.0pt "Times New Roman"">        </span></span></span><u></u><span style="line-height:105%">If yes, is there a different way to edit the data in batch mode? (round about 5000 buildings have to be updated)<u></u><u></u></span></p><p><u></u><span style="line-height:105%"><span>-<span style="font:7.0pt "Times New Roman"">        </span></span></span><u></u><span style="line-height:105%">Are there other ways to Access shp-files in a SQL-like manor to perform that UPDATE Statements?<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Hope you can help me out here.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Best regards,<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></p><span class="HOEnZb"><font color="#888888"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Stephan<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p></font></span></div></div><br>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br></blockquote></div><br></div>