This content has been marked as final. Show 4 replies
Vedant wrote:Is it a manual tabular form or wizard generated one?
I am working on apex 4.1.
I am working of tabular form.
My primary key column name is LINE_ID NUMBER TYPE.
On custom pl/sql function i have written code
I want to increment mY LINE_ID COLUMN ON ADD ROW BUTTON of tabular form.
declare abc number; begin select NVL(max(line_id),0)+1 into ABC from ACT_SEG; return abc; end;
But it is Incrementing on submit button.
After inserting one row how i can increment my LINE_ID ON add_row button.A similar issue has been discussed in the thread below:
Add sequence to Tabular form Add Row?
Vedant wrote:Since LINE_ID is your primary key column, I suggest that you create it in the database instead of writing JS code to populate your tabular form column.
This is wizard generated form. and how i can do this with item or DB.
Line_id is my PRIMARY_KEY COLUMN. There is no option for pass default item or function.
Could you explain in detail.
When you create the tabular form using the wizard, one of the steps is to select the primary key column and the next is to identify the method to populate the primary key. You get 3 options - Existing Trigger, Custom PL/SQL Function and Existing Sequence.
You can choose any one of the 3 options. I think, you are currently using "Custom PL/SQL Function" option. This function will create the primary key value at the time of insert. Since, the Add Row button doesn't perform any database I/O (unless explicitly specified), you do not see the result of the pl/sql function. The "Submit" function calls the "ApplyMRU" process to perform the insert for new records. The custom pl/sql function is therefore, called to generate the primary key for you.
Do you have any requirement to show to the users what primary key value will be generated when they hit the "Add Row" button? If yes, the option is to set default value for the column under Column Attributes -> Tabular Form Attributes -> Default Type and Default. An example is shown here:
So, if your function name is my_func(), you can have the Default Type as "PLSQL Expression or Function" and Default as the function name - my_func()
But, I believe the default value is not re-computed every time. See Arie's comment in the thread below:
Tabular form - Default Value
Therefore, the better option would be to have the submit process handle the primary key creation.
Hope the above explanation helps.