[GRASS-SVN] r37698 - grass/branches/releasebranch_6_4/lib/db/sqlp
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 1 10:15:34 EDT 2009
Author: neteler
Date: 2009-06-01 10:15:34 -0400 (Mon, 01 Jun 2009)
New Revision: 37698
Modified:
grass/branches/releasebranch_6_4/lib/db/sqlp/description.html
Log:
+type casting
Modified: grass/branches/releasebranch_6_4/lib/db/sqlp/description.html
===================================================================
--- grass/branches/releasebranch_6_4/lib/db/sqlp/description.html 2009-06-01 14:15:25 UTC (rev 37697)
+++ grass/branches/releasebranch_6_4/lib/db/sqlp/description.html 2009-06-01 14:15:34 UTC (rev 37698)
@@ -82,13 +82,13 @@
<p>
-<p>Example of subquery expressions from a list (does not work for DBF driver):
+<p><b>Example</b> of subquery expressions from a list (does not work for DBF driver):
<div class="code"><pre>
v.db.select mysites where="id IN ('P04', 'P05')"
</pre></div>
-<p>Example of pattern matching:
+<p><b>Example</b> of pattern matching:
<div class="code"><pre>
# field contains string:
@@ -104,7 +104,7 @@
v.db.select mysites where="id LIKE 'P%'"
</pre></div>
-<p>Example of null handling:
+<p><b>Example</b> of null handling:
<div class="code"><pre>
v.db.addcol map=roads col="nulltest int"
v.db.update map=roads col=nulltest value=1 where="cat > 2"
@@ -113,7 +113,7 @@
</pre></div>
-<p>Examples of complex expressions in updates (using v.db.* modules):
+<p><b>Examples</b> of complex expressions in updates (using v.db.* modules):
<div class="code"><pre>
v.db.addcol map=roads col="exprtest double precision"
v.db.update map=roads col=exprtest value=cat/nulltest
@@ -121,7 +121,7 @@
</pre></div>
-<p>Examples of complex expressions in updates (using db.* modules):
+<p><b>Examples</b> of complex expressions in updates (using db.* modules):
<div class="code"><pre>
echo "UPDATE roads SET exprtest=null"
echo "UPDATE roads SET exprtest=cat/2" | db.execute
@@ -140,7 +140,19 @@
</pre></div>
+<p><b>Example</b> of changing a SQL type (type casting, does not work for DBF driver):
+<div class="code"><pre>
+# North Carolina data set: convert string column to double precision
+# copy map into current mapset
+g.copy vect=geodetic_pts,mygeodetic_pts
+v.db.addcol mygeodetic_pts col="zval double precision"
+# the 'z_value' col contains 'N/A' strings, not to be converted
+v.db.update mygeodetic_pts col=zval \
+ qcol="CAST(z_value AS double precision)" \
+ where="z_value <> 'N/A'"
+</pre></div>
+
<h2>SEE ALSO</h2>
<a href="databaseintro.html">Database management in GRASS GIS</a>,<BR>
More information about the grass-commit
mailing list