[GRASS-SVN] r65874 - grass/branches/releasebranch_7_0/lib/db/sqlp

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 10 06:56:43 PDT 2015


Author: neteler
Date: 2015-08-10 06:56:43 -0700 (Mon, 10 Aug 2015)
New Revision: 65874

Modified:
   grass/branches/releasebranch_7_0/lib/db/sqlp/sql.html
Log:
sql manual: Example of conditions added

Modified: grass/branches/releasebranch_7_0/lib/db/sqlp/sql.html
===================================================================
--- grass/branches/releasebranch_7_0/lib/db/sqlp/sql.html	2015-08-10 13:56:03 UTC (rev 65873)
+++ grass/branches/releasebranch_7_0/lib/db/sqlp/sql.html	2015-08-10 13:56:43 UTC (rev 65874)
@@ -187,6 +187,18 @@
 v.db.update vectormap column=column3 qcolumn="column1 || column2"
 </pre></div>
 
+<h3>Example of conditions</h3>
+
+Conditions (like if statements) are usually written as CASE statement in SQL:
+
+<div class="code"><pre>
+v.db.update vectormap column=species qcolumn="CASE WHEN col1 >= 12 THEN cat else NULL end"
+
+# a more complex example with nested conditions
+v.db.update vectormap column=species qcolumn="CASE WHEN col1 >= 1 THEN cat WHEN row = 13 then 0 ELSE NULL end"
+</pre></div>
+
+
 <h2>SEE ALSO</h2>
 
 <em>



More information about the grass-commit mailing list