Thanks Joe for sharing this. I tried the recommendation however the behaviour is still same. Below is updated code where I am trying to set the Primary Key of Master form in Detail form rows.
for i in apex_application.g_f03.first..apex_application.g_f03.last
apex_application.g_f03(i) := :P35_TRN_ID;
As explained earlier, this code doesnt work when there is single row for update. IF there are more than 1 row everything works perfect.
I believe you have found the problem correctly but not sure how to resolve this! Thanks once again for helping out on this.
your approach seems right.
Things you might want to check/debug ( for example insert the values into a testtable ) is the value of apex_application.g_f12.count to see if this is actually 1 less then expected (BWT I dont think you should start at 0 but at 1 when counting as for i in 1 ..apex_application.g_f12.count).
You might want to check if apex_application.g_f12.count is a checkbox ( if it is the value of apex_application.g_f12.count is only the number of checked checkboxes ), so make sure the apex_application.g_fXX.count is for a NON-checkbox field.
If all else fails you might want to setup a test on apex.oracle.com so we can check to see why it does not work as expected.
The field I used which is apex_application.g_f03.last is a text box. However, its good to know that check box can cause problem. I will keep that in mind.
I had also bebug to find out the counts are right. And in deed they are all correct. What I observed is, If I add 1 row to details table, the "complete" code gets executed once. If I add 2 rows to detail table, "complete" code gets executed twice. I am guessing that when this code is getting executed for the second time, only then it is updating the values even for first row.
I guess if I set up things on apex.oracle.com, it would be easier for you to help me out, I will do it and get back soon. Till then if whatever I wrote rings bells let me know
I have setup the application at http://apex.oracle.com/pls/apex/f?p=17163::2906738421910
login id :demo
Once you Login to application
- Go To "Transactions" Tab - its last TAB
- Click on Create button.
- Select any Transaction date
- Click on Add Row Button in details section
- Enter Purity as 95
- QTY as 10
- GROSS WEIGHT as 100
- NET WEIGHT as 100
- PERCENTAGE as 4
- GOLD RATE as 3000
dont worry about fields not mentioned here, they are either not mandatory or are populated automatically.
11. click on Create.
You will notice that Detail Record doesnt get populated. In Database, the record is getting saved but the Foriegn Key is not getting set.
Now just to make sure that things work with multiple record, you may repeat ADD ROW process once more with same values or similar values.
I have used the Process named: SetTrnId to set the value of Master's Primary Key in Details Section. This gets fired after ATS_Transaction_Master process which returns Trn_id (Primary Key) in the text box.
Let me know if you need any more information.
fixed the foreign key setting process. I think this proces was of a wrong type, I could not find the problem right away so I recreated a PL/SQL process (set_foreign_key) which does the same logic and iot worked right away. So you might compare with the process you created to see what was wrong.
I also changed the type of the field in the report, I'm not sure if the way you created the foreign key in the report creates an g_f0X array, but you can easily check if you revert to the orig type.
First of all THANKS A TON!!! I cant express how happy I am to see my complete application working.
Now here is the story. When I compared the two process, the difference was, I had selected Tabular Form value also! However, in your case, you didnt select it. I replicated the process the way you created and it works PERFECT! May I know why it wont work when we select tabular form? I thought that was needed for the process to work on this form.
I am marking your replies as Helpful as well as Correct Answer. Thanks once again!
not sure what the exact difference is but if you need a multirow update/delete etc pocess you need to choose the page tabular process type.
Also I think for the PL/SQL process type you are able to choose to execute on a per row or per transaction basis (when of type tabular), the standard PL/SQL proc does not have this option.
Probably the difference is not that big, I think you can develop the same results in 2 differend ways.
Maybe this explains it better (compare the standard and tabular ) :