Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7830883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:26:57+00:00 2026-06-02T11:26:57+00:00

So basically my problem is this. I have an sql statement which is obtained

  • 0

So basically my problem is this. I have an sql statement which is obtained from a table in my database. This SQL statement hasd placeholders in it for prepared statement variables. I am using a wrapper class to take care of replacing the variables. The wrapper class deals with ensuring they are the correct type when passed through to PostgreSQL. I am getting syntax errors in my statement which are driving me mad. Part of the prepared statement is a string used in a ST_GeomFromText() function. This string has its values populated by way of prepared statement variables. Oddly the variables are not just being concatenated into the string but are being treated as individual entities by the looks of the errors I receive. See below for examples of queries I have tried and error messages.

Can anyone shed any light on this? It is driving me mad. I have to be able to build this geometry from text and the parameters must be able to be passed via a prepared statement. I have followed the trail in C# and it ends passing the values into my command object parameters as string so there is not conversion going on in the code that I am able to view that would make these be treated as anything but strings.

Statements (as returned from the table)

Number 1. With values

select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy 
from 
   ST_ENVELOPE(
       ST_TRANSFORM(
          ST_GeomFromText('POLYGON(('||138082||' '||12907||','||207179||' '||12907||','||207179||' '||88647||','||138082||' '||88647'||','||138082||' '||12907||'))',27700),4326)) 
as a

Number 1. Without values

select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy 
from 
   ST_ENVELOPE(
      ST_TRANSFORM(
         ST_GeomFromText('POLYGON(('||:0||' '||:1||','||:2||' '||:3||','||:4||' '||:5||','||:6||' '||:7'||','||:8||' '||:9||'))',27700),:10)) 
as a

Number 2. With values

select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy
from 
   ST_ENVELOPE(
      ST_TRANSFORM(
         ST_GeomFromText($$POLYGON((138082 12907, 207179 12907, 207179 88647, 138082 88647, 138082 12907))$$,27700), 4326)) 
as a

Number 2. With values

select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy
from 
   ST_ENVELOPE(
      ST_TRANSFORM(
         ST_GeomFromText($$POLYGON((:0 :1, :2 :3, :4 :5, :6 :7, :8 :9))$$,27700),:10)) 
as a;

Errors from PostgreSQL log:

Number 1

2012-04-18 09:39:41 BST ERROR:  syntax error at or near "'||'" at character 283
2012-04-18 09:39:41 BST STATEMENT:  select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy from ST_ENVELOPE(ST_TRANSFORM(ST_GeomFromText('POLYGON(('||((E'138082'))||' '||((E'12907'))||','||((E'207179'))||' '||((E'12907'))||','||((E'207179'))||' '||((E'88647'))||','||((E'138082'))||' '||((E'88647'))'||','||((E'138082'))||' '||((E'12907'))||'))',27700),((E'4326')))) as a

Number 2

09:39:27 BST ERROR:  parse error - invalid geometry
2012-04-18 09:39:27 BST HINT:  "POLYGON(((" <-- parse error at position 10 within geometry
2012-04-18 09:39:27 BST STATEMENT:  select st_xmin(a) minx, st_ymin(a) miny, st_xmax(a) maxx, st_ymax(a) maxy ,1, 1 from ST_ENVELOPE(ST_TRANSFORM(ST_GeomFromText($$POLYGON((((E'464217')) ((E'133902')), ((E'591014')) ((E'133902')), ((E'591014')) ((E'261209')), ((E'464217')) ((E'261209')), ((E'464217')) ((E'133902'))))$$,27700),((E'4326')))) as a;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:26:59+00:00Added an answer on June 2, 2026 at 11:26 am

    Your first error is a simple syntax error with an extra ' character, at character row 283. Change 88647'|| to 88647||, and :7'|| to :7|| for your without value version.

    I can’t reproduce your second error.

    On the topic of MBR, have you seen the box functions/types? They could help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a giant SQL Server 2005 database (75GB) which basically is just data
I have basically the same problem outlined in this question, however I am using
The problem is basically this, in python's gobject and gtk bindings. Assume we have
This is basically a math problem, but very programing related: if I have 1
I am having a problem getting this code to work. Basically I Go from
I have an SQL query from SQL Server which returns dates as a string
I have this problem. Given a users table that consists of users' username in
I have a log table in SQL Server. Table is structured this way: Unique
So basically I have been trying to insert columns into my third table from
Im stuck with this little project in C# but basically my problem is this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.