Bruno Zerbo
2013-04-06 09:27:48 UTC
hi,
I'm working with an app that makes some query to a postgres db.
I tried the following query with pgadmin and it works while thought the c++
code I have a runtime error.
This is the code:
using namespace soci;
Edge edge;
soci::session sql(postgresql, "hostaddr=127.0.0.1 user=postgres
password=aurali port=5432 dbname=routing");
sql << "SELECT gid, source, target, the_geom,
name,ST_Distance(the_geom, ST_GeometryFromText('POINT(15.1118 37.5667)',
4326)) AS dist FROM ways WHERE the_geom && setsrid('BOX3D(15.0118 37.4667,
15.2118 37,6667)'::box3d, 4326) ORDER BY dist LIMIT 1"
, into(edge.gid), into(edge.source),
into(edge.target), into(edge.the_geom), into(
edge.name);
std::cout << "edge found: " << edge.name << " " << edge.gid<< " " <<
edge.source << edge.target << edge.the_geom;
return edge;
the application gives my the following error:
"Wt: fatal error: ERROR: syntax error at or near ""$1""
LINE 1: ...etsrid('BOX3D(15.0118 37.4667, 15.2118 37,6667)'::$1, 4326) ...
the error is given in place of $1 that in the query is ::box3d. Why? there
was this traslation? Maybe is the double colons that gives the problem? How
I can fix? How to pass a colon in the sql string?
thanks, Bruno
I'm working with an app that makes some query to a postgres db.
I tried the following query with pgadmin and it works while thought the c++
code I have a runtime error.
This is the code:
using namespace soci;
Edge edge;
soci::session sql(postgresql, "hostaddr=127.0.0.1 user=postgres
password=aurali port=5432 dbname=routing");
sql << "SELECT gid, source, target, the_geom,
name,ST_Distance(the_geom, ST_GeometryFromText('POINT(15.1118 37.5667)',
4326)) AS dist FROM ways WHERE the_geom && setsrid('BOX3D(15.0118 37.4667,
15.2118 37,6667)'::box3d, 4326) ORDER BY dist LIMIT 1"
, into(edge.gid), into(edge.source),
into(edge.target), into(edge.the_geom), into(
edge.name);
std::cout << "edge found: " << edge.name << " " << edge.gid<< " " <<
edge.source << edge.target << edge.the_geom;
return edge;
the application gives my the following error:
"Wt: fatal error: ERROR: syntax error at or near ""$1""
LINE 1: ...etsrid('BOX3D(15.0118 37.4667, 15.2118 37,6667)'::$1, 4326) ...
the error is given in place of $1 that in the query is ::box3d. Why? there
was this traslation? Maybe is the double colons that gives the problem? How
I can fix? How to pass a colon in the sql string?
thanks, Bruno