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

  • Home
  • SEARCH
  • 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 6206809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:30:58+00:00 2026-05-24T05:30:58+00:00

I am currently using PostgreSQL 9.0.4 database with JDBC driver: postgresql-9.0-801.jdbc4.jar . I have

  • 0

I am currently using “PostgreSQL 9.0.4” database with JDBC driver: “postgresql-9.0-801.jdbc4.jar“.

I have the following JDBC SQL using “SELECT… FOR UPDATE OF…” clause which retrieves a column value (long) and updates the value by incrementing in same transaction.

I need to return the long value, thus I need to use SELECT Sql.

final PreparedStatement preparedStatement = _connection.prepareStatement(
              "select value from sequence where table_name='JOB' for update of value",
                  ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);

 long ret;
 try {
      final ResultSet resultSet = preparedStatement.executeQuery();
      resultSet.next();
      ret = resultSet.getLong(1);
      resultSet.updateLong(1, ret + 1);
      resultSet.updateRow();
 } catch (SQLException ex) {
      ex.printStackTrace(); 
 } 
finally {
     resultSet.close();
     preparedStatement.close();
 }
 return ret;

All other databases e.g. MySQL, Oracle, MS-SQL, Derby work fine with such SQL – but PostgreSQL always throws following exception.

     org.postgresql.util.PSQLException: ERROR: relation "value" in FOR UPDATE/SHARE clause not found in FROM clause
     Position: 68

I do have the table “sequence” with the “value” column properly created – so this may not be the infamous case-sensitivity issue.

Does this mean Postgres does not support “SELECT …FOR UPDATE OF..” SQL syntax?

In that case what will be the best way to achieve the same effect (i.e. select and update with the same transaction)?

Many thanks in advance,

  • 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-05-24T05:31:01+00:00Added an answer on May 24, 2026 at 5:31 am

    Yes. It is supported. BUT the syntax is

    FOR UPDATE [ OF table_name [, ...] ] [ NOWAIT ]

    You can see more here:

    http://www.postgresql.org/docs/8.2/static/sql-select.html#SQL-FOR-UPDATE-SHARE

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

Sidebar

Related Questions

I have an existing PostgreSQL database that I'm using for a new Django site.
I'm using Hibernate and PostgreSQL 8.4 database in a Java application. I have the
I'm using psycopg2 to access a postgresql 8.4 database, and on an update query
I currently have to implement a query on a postgres database using a prepared
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
I am currently using Windows Server 2008 Standard and have several Hyper V machines.
I am currently using the following command to upload my site content: scp -r
We are currently building a PostgreSQL database that allows us to create profiles for
We are currently deploying some applications on a glassfish 3.0.1 using a postgres database
We're currently migrating our database back-end from Firebird to PostgreSQL. We use NHibernate as

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.