<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix"><a class="moz-txt-link-freetext"
href="http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/sp-view.html">http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/sp-view.html</a>
      recommend to insert spatial view in <font face="Courier New,
        monospace"><b>views_geometry_columns.</b></font><br>
      <br>
      Note: I had problems trying to use OGC_FID instead of ROWID as the
      PK for the view.<br>
      <br>
      On 23/01/2014 09:26, Geo DrinX wrote:<br>
    </div>
    <blockquote
cite="mid:CAFF9ZhtCibQ53Z8JxGGdM7jrG9inFaUB3aikEh3_tmKR=_kuFw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Hello all,<br>
          <br>
          <br>
          <span id="result_box" class="" lang="en"><span class="">I
              noticed</span> <span class="">a strange</span> <span
              class="">behavior</span> in QGis <span class="">when I am
              viewing</span>  <span class=""></span></span><span
            id="result_box" class="" lang="en"><span class=""><span
                id="result_box" class="" lang="en"><span class="">SpatiaLite
                </span></span>view</span>s</span>.<br>
          <br>
        </div>
        <div>These are my steps:<br>
          <br>
        </div>
        <div>1)  I have some SpatiaLite tables, that have  "Geometry"
          field.  For example:<br>
          <br>
          <span id="result_box" class="" lang="en"><span class="">CREATE
              TABLE "Poligoni" (<br>
              "PK_UID" INTEGER PRIMARY KEY AUTOINCREMENT,<br>
              "field1" TEXT,<br>
              "Note" TEXT, "geometry" POLYGON)</span></span><br>
          <br>
        </div>
        <div>2) I create a SpatiaLite view, that performs some spatial
          opetation, i.e.  an intersection<br>
          <br>
          CREATE VIEW intersecato as<br>
          SELECT  b.field1as "field1", b."field2" AS "field2",
          a."field3" AS "field3",<br>
              ST_area (a.Geometry) AS "area", b.arec as "arec", <br>
           intersection (a.Geometry, b.Geometry) as Geometry<br>
          FROM "Poligoni" a, "otherTable" b<br>
          where<br>
          ST_intersects (a.Geometry, b.Geometry)  = 1<br>
          order by field1<br>
          <br>
        </div>
        <div>3)  I insert into "geometry_columns" a record for the view:<br>
          <br>
          insert into geometry_columns values<br>
          ('intersecato','geometry',3,2,3003,0)<br>
          <br>
          <br>
        </div>
        <div>4)  I execute a query into SpatiaLite_gui to control that
          some record exists.<br>
        </div>
        <div>     And...  they exist.   :)<br>
          <br>
          <br>
        </div>
        <div>5) I go to QGis (2.0.1 Dufour,  Windows, Linux or MacOSX :)
            and connect to SpatiaLite DB.<br>
          <br>
        </div>
        <div>6) I insert my tables and view in Layer list.<br>
          <div id="gt-src-tools">
            <div id="gt-src-tools-l">
              <div style="display:inline-block" id="gt-input-tool">
                <div id="itamenu"><span class=""></span></div>
              </div>
            </div>
          </div>
          <div id="gt-res-content" class="">
            <div dir="ltr" style="zoom:1"><span id="result_box" class=""
                lang="en"><span class="">We, now</span> <span class="">I
                  see</span> <span class="">all the layers</span><span
                  class="">,</span> <span class="">as those</span> <span
                  class="">corresponding</span> <span class="">to the
                  tables, as that</span> <span class="">correspond to</span>
                <span class="">my SpatiaLite view.  But, this one do not
                  display the correct records in the attribute panel: 
                  in this case, I only have a list of many "NULL", and
                  selecting a record, all records are selected  :(<br>
                  <br>
                  <br>
                </span></span></div>
            <span id="result_box" class="" lang="en"><span class="">Do
                you have any</span> <span class="">explanation for this</span><span
                class="">?<br>
                <br>
              </span></span></div>
          <div id="gt-res-content" class="">
            <span id="result_box" class="" lang="en"><span class="">Also
                I tried to add a PK_UID  in the view definition, but the
                result remains the same.<br>
                <br>
                <br>
              </span></span></div>
          <div id="gt-res-content" class=""><span id="result_box"
              class="" lang="en"><span class="">Thank you for any help<br>
                <br>
              </span></span></div>
          <div id="gt-res-content" class=""><span id="result_box"
              class="" lang="en"><span class="">Regards<br>
                <br>
              </span></span></div>
          <div id="gt-res-content" class=""><span id="result_box"
              class="" lang="en"><span class="">Roberto<br>
              </span></span></div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Qgis-developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
    </blockquote>
    <br>
  </body>
</html>