I'm trying to do a dblink using a postgis function, but the linestring has given me many problems.
SELECT
DV3."XXX",
s."QQQID",s."X",s."Y",a."PPP"
FROM
"QQQ" s INNER JOIN "AAA" a ON a."QQQID" = s."QQQID",
dblink('dbname=ZZZ',
'SELECT XXX,the_geom
FROM "geometry", "QQQ" s
WHERE box2d(geomfromtext(''LINESTRING('|| s."X" ||' '||s."Y" ||','|| s."X" || ' '||s."Y" || ')'',2309))
&& the_geom'
)
DV3("XXX" INTEGER,"the_geom" geometry)
WHERE
contains(DV3.the_geom,geomfromtext('POINT('|| s."X" ||' '|| s."Y" ||')',2309))--21
AND "GGG" IS NOT NULL
ERROR
LINE 9: ... WHERE box2d(geomfromtext(''LINESTRING('|| s."X" + 0....