Getting the Unique Key

Results 1 to 5 of 5

Thread: Getting the Unique Key

  1. #1
    Scott A. Guest

    Default Getting the Unique Key

    OK, I&#039;m using both Oracle and SQLServer with ASP (ADO) on unrelated projects. Is there any "standard" way to get a system-generated, unique key from the database after doing an insert? I need the new key back after doing the insert so I can create some child records in other tables.<BR><BR>I&#039;ve already thought of the "create-your-own-key-for-the-insert-then-select-it-and-get-the-unique-one-in-the-process" solution. I was hoping there was something more efficient than that. That solution has about as much appeal as a broken bottle full of anthrax. Especially since I will have a Titanic-sized load of tables. There has to be an easier standard way, even if it&#039;s database specific. <BR><BR>Thanks,<BR>Scott

  2. #2
    Join Date
    Dec 1969

    Default Look at this...

  3. #3
    Scott A. Guest

    Default RE: Look at this...

    Hey, Bill <BR>If I would&#039;ve gotten it answered the first time I wouldn&#039;t have crossed it....any ideas on my actual problem?<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default Not sure but..

    Not sure if it is what you want,but:<BR>You can write trigger(sql server) on "insert" which will give you output with a new inserted value.

  5. #5
    jamar Guest

    Default RE: Getting the Unique Key

    For SQL Server:<BR>1. After you commit the record by updating the recordset open a second recordset using the query below: <BR> "select @@identity as &#039;NewGeneratedID&#039; from table " <BR><BR>--This should give you what you need<BR><BR>I&#039;m not sure about Oracle. hope this helps.

Posting Permissions

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