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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:52:40+00:00 2026-05-25T06:52:40+00:00

In Postgres, I can write INSERT .. RETURNING * To retrieve all values that

  • 0

In Postgres, I can write

INSERT .. RETURNING *

To retrieve all values that had been generated during the insert. In Oracle, HSQLDB, I can use

String[] columnNames = ...
PreparedStatement stmt = connection.prepareStatement(sql, columnNames);
// ...
stmt.execute();
stmt.getGeneratedKeys();

To retrieve all values that had been generated. MySQL is a bit limited and only returns columns that are set to AUTO_INCREMENT. But how can this be done with Sybase SQL Anywhere? The JDBC driver does not implement these methods, and there is no INSERT .. RETURNING clause, as in Postgres. Is there way to do it, other than maybe running

SELECT @@identity

immediately after the insert?

  • 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-25T06:52:41+00:00Added an answer on May 25, 2026 at 6:52 am

    My current implementation executes three consecutive SQL statements:

    -- insert the data first
    INSERT INTO .. VALUES (..)
    
    -- get the generated identity value immediately afterwards
    SELECT @@identity
    
    -- get the remaining values from the record (possibly generated by a trigger)
    SELECT * FROM .. WHERE ID = :previous_identity
    

    The third statement can be omitted, if only the ID column is requested

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

Sidebar

Related Questions

How can I write an SQL query that returns a record only if ALL
I want to create a postgres user that can access only one database on
Can anyone help with a Postgres syntax problem? I'm trying to insert a record,
Hi I find that on postgres database, we can't configure default accent sensivity (on
In postgres you can do a comparison against multiple items like so: SELECT 'test'
In postgres I am fairly sure you can do something like this SELECT authors.stage_name,
I have two tables (in postgres) - ads and logs. After every insert into
Since Postgres can only add columns at the end of tables, I end up
I am just beginning to learn how to write software that accesses an SQL
EDIT: I have been using Postgres with PostGIS for a few months now, and

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.