Skip to Main Content

APEX

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!

Setting the default value of a column via SQL in an interactive grid

Del17Mar 4 2020 — edited Mar 6 2020

Hello,

I am trying to create an automatic value in an interactive grid column when a new record is created.

I have tried putting the SQL below in as the default value:

SELECT MAX(LINE_NUMBER)+1 FROM UMA_LIS_TRANSECT_PROG WHERE LOIS_CODE = P27_LOIS_CODE.

and setting a page item P27_LOIS_CODE with a dynamic action to load its value.

The dynamic action is

$(this.triggeringElement).parent().data('id').  I presume it gets the PK on the parent region/table which in my case is LOIS_CODE.

But no luck.

So I tried creating a dynamic item that sets the value of the column LINE_NUMBER once the first column is selected.  I.e. with a GET FOCUS dynamic action as below:

Dynamic Action is called Load_LOIS

True actions are:

SET VALUE with the javascript "$(this.triggeringElement).parent().data('id')".  Again I presume this gets the PK of the parent region/table.

EXECUTE PL/SQL CODE

     UPDATE LINE_NUMBER SET = SELECT MAX(LINE_NUMBER)+1 FROM IRIS.UMA_LIS_TRANSECT_PROG WHERE LOIS_CODE = :P27_LOIS_CODE;

I have also tried

     SELECT MAX(LINE_NUMBER)+1 INTO &LINE_NUMBER. WHERE LOIS_CODE = :P27_LOIS_CODE;

Neither have correct syntax.

Has anybody any suggestions on how I can set the value of LINE_NUMBER to MAX + 1 when creating a new record within an interactive grid?

Thank You,

Derek.

Comments
Post Details
Added on Mar 4 2020
4 comments
1,634 views