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 8529963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:08:57+00:00 2026-06-11T09:08:57+00:00

I have this parameterized query in an Npgsqlcommand: UPDATE raw.geocoding SET the_geom = ST_Transform(ST_GeomFromText(‘POINT(:longitude

  • 0

I have this parameterized query in an Npgsqlcommand:

UPDATE raw.geocoding
SET the_geom = ST_Transform(ST_GeomFromText('POINT(:longitude :latitude)', 4326),3081)
WHERE id=:id

:longutide and :latitude are double, and id is int.

The query that is actually run against the DB looks like this:

UPDATE raw.geocoding
SET the_geom = ST_Transform(ST_GeomFromText('POINT(((E'-96.6864379495382')::float8) ((E'32.792527154088')::float8))', 4326),3081)
WHERE id=((10793455)::int4)

Thanks to help from Erwin Brandstetter here, it’s apparent that the query needs to be simplified to work with PostGIS. He suggested this:

UPDATE raw.geocoding
SET    the_geom = ST_Transform(ST_GeomFromText(
                  $$POINT(:longitude :latitude)$$::geometry, 4326), 3081)
WHERE  id = :id

I guess I could create this with a dynamic query, where I manually update the query every time I run it, but is there a way to make this work with a Npgsql parameterized query?

  • 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-11T09:08:58+00:00Added an answer on June 11, 2026 at 9:08 am

    I am not an expert with npgsql, but I think your parameterized query could work like this:

    UPDATE raw.geocoding
    SET    the_geom = ST_Transform(ST_GeomFromText(:mygeom, 4326), 3081)
    WHERE  id = :id
    

    And mygeom would hold this string:

    POINT(96.6864379495382 32.792527154088)
    

    .. pre-assembled from your other variables. Would result in a query like this:

    UPDATE raw.geocoding
    SET    the_geom = ST_Transform(ST_GeomFromText(
                 (E'POINT(96.6864379495382 32.792527154088)')::text, 4326),3081)
    WHERE  id=((10793455)::int4)
    

    Which should work.


    If you have trouble assembling the string (like your comment demonstrates), there is a more elegant way. As per hint from @Paul on my previous answer – PostGIS provides a dedicated function for the purpose:

    ST_MakePoint(double precision x, double precision y)
    

    Details in the manual. With this, we finally arrive at:

    UPDATE raw.geocoding
    SET    the_geom = ST_Transform(ST_SetSRID(
                   ST_MakePoint(:longitude, :latitude), 4326), 3081)
    WHERE  id = :id
    

    Note the comma. Will it finally work now?
    If not, just beat it with a sledgehammer. Grml.

    It does – with ST_SetSRID() now instead of ST_GeomFromText(). See comment.

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

Sidebar

Related Questions

Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Recently I have been writing parameterized queries like this: SQL = INSERT INTO myTable
I have a query that, basically, says this: SELECT DISTINCT [DB_ID] FROM [TableX] WHERE
I have this hql query, which works perfect: select m from Media m join
I have a query in a TableAdapter that wrapped this SQL (Oracle SQL, uses
I have an SQL query that goes like this: $stmt = $dbh->prepare(INSERT INTO Places
I have a parameterized query. Depending on parameter values optimal query plan varies significantly.
I have the following query and I want to make it a parameterized query.
I have a string that looks like this: set @sqlstring = N'select @mindate =
I have a SQL query which is parameterized by a very limited in-house framework.

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.