1 Reply Latest reply on Sep 14, 2009 9:42 PM by gaverill

    How can I obtain ID from new object?

      I have the following object
      create or replace type ADDRESS_T as object
            address_id NUMBER, 
            town_id VARCHAR2,
            street_id VARCHAR2, 
            house NUMBER, 
            apartment NUMBER
      and the corresponding table and object view.
      Also I have trigger and sequence for autoincrementing field address_id.
      I create object in my C++ code like this:
      ADDRESS_T* addr = new(conh->connection(), "ADDRESS_VIEW")ADDRESS_T;
      How can I obtain address_id value from this new object?
      I mean the value that will be inserted by trigger.
        • 1. Re: How can I obtain ID from new object?
          i don't believe object view "instead of" triggers allow for a "returning" clause, so it's not possible to use that mechanism to return the trigger-assigned value.

          two other possibilities include:

          1) have your code instead call a stored function which assigns the id (rather than the trigger) and then inserts the object; return the assigned value to your calling code.

          2) modify your trigger to set a package variable with the assigned id value; inspect the package variable after insert.

          hope that helps...