Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to create single trigger for INSERT/UPDATE operations

BommiApr 2 2021

Hi Team,

We are using R12.2.3.
We need to create a trigger on Inventory Items. We have DFF enabled at Item header level.
Now, the trigger has to load data into custom table XX_ITEM_AUDIT whenever new item is created or when ever DFF attribute6 is updated.

I am not able to achieve this in single trigger. So I created 2 separate triggers: for INSERT and other for UPDATE. Questions and help required here

INSERT related trigger has to fire whenever a new item is created
UPDATE related trigger has to fire whenever attribute6 is updated on Inventory Item. For me, what ever the field is updated on item, this UPDATE trigger is being fired. But we want this to be fired only when attribute6 is updated (NULL is not allowed for this attribute6 as we made it as mandatory DFF element).
It will be more helpful if both the triggers are merged and created as a single trigger
We want the custom table to be created in custom schema and grant permissions(Only SELECT,INSERT) to APPS schema.
I connected to APPS schema and created this table (As we dont have permissions and password to connect to custom schema) and tried the below command directly from APPS schema to provide grants to APPS schema itself. But this command is not working

EXEC APPS.APPS_DDL.APPS_DDL('GRANT select, insert, update ON XXNPI.XX_INV_ITEM_AUDIT TO APPS WITH GRANT OPTION');

Attached the sample table and triggers I created.
Please help me on this

Thanks in Advance,
Bommi
For Community.txt (1.98 KB)

Comments

John JB Brock-Oracle

The only thing I can think of to look at first would be if the keyAttributes value that you have set in your DataProvider is truly a uniqueId and you do not have duplicates in your dataset.

User_77VTN

I have faced similar issue and the suggestion solved. I was using a column 'code' as id Attribute where in reality it is not unique between rows. So changed the idAttribute to 'id' instead of 'code'.(Note: 'id' is not a column. It just took its own ref). Then the data got auto refreshed as soon as the observable is changed.

----------------------------------------------------------------------------------------- JS code -----------------------------------------

self.testArr = ko.observableArray();

//self.testDS = new PagingDataProviderView(new ArrayDataProvider(self.testArr, { idAttribute: 'code' }));  ===> REFRESH NOT WORKING

self.testDS = new PagingDataProviderView(new ArrayDataProvider(self.testArr, { idAttribute: 'id' })); //// REFRESH WORKING

self.testCols = ko.observable();

self.testCols([{

        "headerText": "code",

        "field": "code",

        "id": "test_code"

      },

      {

        "headerText": "amount",

        "field": "amnt",

        "id": "test_amnt"

      }

      ]);

var dir1 ={ "code":"c1","amnt":100 };

self.testArr.push(dir1);

var dir2 ={ "code":"c1","amnt":20 };

self.testArr.push(dir2);

-----------table------------------------------------------------------------------------------------------------------------------

<oj-table aria-label="Test Table" id="test-details-table" data='[[testDS]]'

                        selection-mode='{"row": "single", "column": "multiple"}' columns='[[testCols]]'

                        columns-default='{"sortable": "disabled" }' row-renderer="[[testTableRowRenderer]]"

                        scroll-policy='loadMoreOnScroll' class="width100">

                        <oj-paging-control class="lastTab" id="test_paging" data='[[testDS]]'

                            page-options='{"type":"Number"}' page-size='5' slot='bottom'>

                        </oj-paging-control>

                    </oj-table>

------------------------------------------------------------------------------------------------------------------------------------

User_77VTN

Check by changing keyAttributes --> from 'departmentId' ti 'id'

Philip Sommer

For completeness sake, let me make the following remarks:

  1. idAttribute is deprecated and you should use keyAttributes instead
  2. Specifying a non-existent field name as 1066874 recommends is not offically supported. Instead, you can simply not specify any keyAttributes, in which case the DataProvider will default to using the array index (which is guaranteed to be unique of course).

Source: https://www.oracle.com/webfolder/technetwork/jet/jsdocs/ArrayDataProvider.html#constructor-section

1 - 4

Post Details

Added on Apr 2 2021
12 comments
15,954 views