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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:25:32+00:00 2026-05-20T08:25:32+00:00

I’m adding new features to a legacy application written in PHP that uses an

  • 0

I’m adding new features to a legacy application written in PHP that uses an Oracle 9i database through the ODBC functions. I’ve created a table that has a sequence and a trigger to generate auto-incrementing IDs.

Now, I’m struggling to find a way to make an insert and obtain the generated ID afterwards:

  • The ODBC library does not appear to have a dedicated lastInsertId method.
  • Running a query with RETURNING clause triggers: ORA-00439: feature not enabled: RETURNING clause from this client type.
  • I’m able to run a RETURNING clause if I enclose it in a BEGIN...END block but it’s of little help: OUT parameters are apparently not supported by the Unified ODBC driver PHP uses.

Do I need to hard-code the sequence name and use SEQ_NAME.CURRVAL in the rest of the transaction? What do I need to do to ensure I get the right value even if there’re concurrent accesses?

Update: added third point to failed attemps

  • 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-20T08:25:33+00:00Added an answer on May 20, 2026 at 8:25 am

    Best bet might be to code this insert as a PL/SQL API on the database side which will return you the ID to use.
    e.g.)

    create function insert_yourtable(p_f1 number, p_f2 varchar2, ... p_fn varchar2)
    return number
       idval number;
    begin
       insert into yourtable(f1, f2,...fn)
       values (p_f1, p_f2, ...p_fn)
       returning your_id_value into idval;
       return idval;
    end;
    /
    

    Then you could call this as a prepared statement to get the out param and use the ID for the rest of your transaction.

    Whoops – just saw the “No OUT params comment….”

    OK, then I guess you need to manage it all from the UI.
    Drop the trigger from the table, do a

    select yourseq.nextval from dual;
    

    to get the next available key value, store it locally, and then do all of the work yourself using the retrieved ID to insert into the ID field in the table. The sequence will ensure that you have transactional security on the ID.

    What a pain in the butt implementation of ODBC!

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

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.