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

TPD-Opitz

The font Arial has "proportional" character widths, that means that an "i" uses less space that a "m"

You could select a fond that is "nonpropotional" so that an "i" occupies the same space as a "m".

The most famous font of this type is  Courier

or you follow this advice:

Calculate the display width of a string in Java - Stack Overflow

bye

TPD

darrylburke

Cross posted and correctly answered at LineBreakMeasurer calculate text length is not match the length of line!

TPD-Opitz, the choice of Font has nothing to do with it.

unknown-7404

I want to draw a line under a text. But the length that I calculate seems not equals to the length of the text.

No! That is NOT true.

The 'length' that you calculate is EXACTLY equal to the length of the text.

int lineWidth = (int)layout.getBounds().getWidth();

That line widths is CORRECT.


But the line you DRAW is not the correct length because you are NOT specifying the parameters to 'drawLine' correctly:

g2d.drawLine(35, 150, lineWidth, 150);

You are using 'lineWidth' as the x coordinate of the second point. See the Java API for the method


Graphics (Java Platform SE 7 )

  • drawLine

     public abstract void drawLine(int x1, int y1, int x2, int y2)
    

    Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.

    Parameters:
    x1 - the first point's x coordinate.
    y1 - the first point's y coordinate.
    x2 - the second point's x coordinate.
    y2 - the second point's y coordinate.

See 'x2' the third parameter? That is "the second points's x coordinate. So it needs to be 'x1' plus the line width; you have to start at x1 and then go the line width to the right.

1 - 3

Post Details

Added on Apr 2 2021
12 comments
15,977 views