<div>Hi !</div>
<div>I try to create a view from a spatial table, but it can't be done successfully, please give me some hints.</div>
<div> </div>
<div>Here is how I create my spatial table:</div>
<div> </div>
<div><strong>CREATE TABLE "table_name" ("ID" SERIAL PRIMARY KEY);<br>SELECT ADDGEOMETRYCOLUMN('', 'table_name', 'geocol', -1, 'MULTIPOLYGON', 2);</strong></div>
<div> </div>
<div>After I inserted 1000 records into this table, I try to create a view with libpq:</div>
<div> </div>
<div><strong>int wkblen=0;</strong></div>
<div><strong>char *pwkb = MakeWKB(&wkblen);</strong> // I wrote a function to make wkb format, the function works fine.</div>
<div><strong>Oid paramtypes[1]={0};</strong></div>
<div><strong>char* paramvalues[1]={pwkb};</strong></div>
<div><strong>int paramlens[1]={wkblen};<br>int paramformats[1]={1};</strong></div>
<div><strong>int resultformat=1;</strong></div>
<div> </div>
<div><strong>PGresult *r = PQexecParams(conn,</strong></div>
<div><strong>              "CREATE VIEW \"view_name\" AS SELECT * FROM \"table_name\" WHERE ST_Intersects(\"geocol\", $1)",</strong></div>
<div><strong>              1,</strong></div>
<div><strong>              paramtypes,</strong></div>
<div><strong>              paramvalues,</strong></div>
<div><strong>              paramlens,</strong></div>
<div><strong>              paramformats,</strong></div>
<div><strong>              resultformat);</strong></div>
<div><strong>ExecStatusType est = PQresultstatus(r);</strong></div>
<div> </div>
<div>The ExecStatusType is always be <strong>PGRES_FATAL_ERROR</strong>, and Error Message is <strong>"could not determine data type of parameter $1"</strong>.</div>
<div>I have no idea what's going on, because when I change the SQL syntax to:</div>
<div> </div>
<div><strong>"SELECT * FROM \"table_name\" WHERE ST_Intersects(\"geocol\", $1)"</strong></div>
<div> </div>
<div>The ExecStatusType will be PGRES_TUPLES_OK.</div>
<div> </div>
<div>Please give me some hints, Thanks !</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>