Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Location
    us.ca
    Posts
    9

    Unanswered: Retrieving an auto-generated key from an insert with java

    There is a table which increments the primary key field by 1 for each new entry.

    Is there a way to retrieve the value of this key?

    for example: AGENTID,AGENTNAME .. the agent id field increments.

    my sql statement that i use with jdbc looks like this: INSERT INTO FILE (AGENTNAME) VALUES('ME')

    and now i need the ID it generated. do i need to do another query?

  2. #2
    Join Date
    Jun 2004
    Posts
    6

    retrieve an auto-generated ID

    Try
    SET :your-receiving-field = IDENTITY_VAL_LOCAL()
    after insert
    This function returns your last inserted id

    By the way this is the COBOL format which may be different a little from Java

    Isaac ElSerafi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •