Forum Stats

  • 3,851,558 Users
  • 2,263,999 Discussions
  • 7,904,779 Comments

Discussions

Submission of a form creating multiple rows in DB table

idm731
idm731 Member Posts: 361
edited Apr 13, 2014 5:06PM in APEX Discussions

Hi All

I have created a new Apex application and have created a table with columns - USER_ID, ADDRESS, PHONE, CREATEDON etc

I want to read the USER_ID of the logged in user and populate this field on the form and populate the CREATEDON field with the system date. These two fields are hidden on the form.

Now when the user fills his address and phone on the form and clicks submit, 3 identical rows are inserted in the DB table. The values of logged in user and system date are successfully set.

To set the USER_ID field, I have inserted $APP_USER. in the default value section of the form. I am not able to understand, why Apex is inserting multiple rows even when the submit button is clicked once.

Please help.

Best Answer

  • idm731
    idm731 Member Posts: 361
    Answer ✓

    The issue is resolved now. I noticed that adding the default values for the form fields added duplicate processes. That is why the form was processed thrice. Removing the additional processes resolved the issue.

Answers

  • kvlek
    kvlek Member Posts: 196

    Hi,

    Are the times in CREATEDON exact the same? 

    If not then one problem could be that the process for the create is executed 3 times. But it could be something else, like triggers or so.

    Have you debug the page to see what is happening after the submit?

    Can you reproduce this problem on apex.oracle.com?

    Regards,

    Kees Vlek

    +If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.+

    kvlek
  • idm731
    idm731 Member Posts: 361

    Thanks Kees for your response. My application is on apex.oracle.com.

    The field CREATEDON has "V('SYSDATE_YYYYMMDD')" as PL/SQL expression set as the default value so it contains only the date and not time.

    The debug details show that the process and execute statements have been executed 3 times (all 3 are identical):

    ===============================================================

    Processes - point: AFTER_SUBMIT

    ...Process "Process Row of MY_GETELDASST" - Type: DML_PROCESS_ROW

    ...Execute Statement: begin begin insert into "XXX"."MY_GETELDASST"

    ...Process "Process Row of MY_GETELDASST" - Type: DML_PROCESS_ROW

    ...Execute Statement: begin begin insert into "XXX"."MY_GETELDASST"

    ...Process "Process Row of MY_GETELDASST" - Type: DML_PROCESS_ROW

    ...Execute Statement: begin begin insert into "XXX"."MY_GETELDASST"

    ...Process "reset page" - Type: CLEAR_CACHE_FOR_PAGES

    ===============================================================

  • Mike Kutz
    Mike Kutz Member Posts: 6,199 Silver Crown
    Thanks Kees for your response. My application is on apex.oracle.com.
    

    So???  How do we access it?

    And... does this app produce the problem?

    (Make sure you create a developer's account so you don't have to post your email address for the spam bots.)

    The field CREATEDON has "V('SYSDATE_YYYYMMDD')" as PL/SQL expression set as the default value so it contains only the date and not time.
    
    

    Coding note:

    store DATEs as DATEs

    if you want "time free" date, TRUNC() the date.

    if CRETEDON is a DATE field, your default value should be:  trunc( sysdate )

    Mike Kutz
  • idm731
    idm731 Member Posts: 361
    edited Apr 13, 2014 5:04PM

    Thanks Mike

    If I remove CREATEDON PL/SQL expression for setting the sysdate then also two rows are inserted in the DB table.

    I think setting the default value for the form field is creating this problem. Is there a better way to get the logged in user and sysdate and populate the form.

    If you login to the application, then you need to go to MyAccount and click on 'Request Elderly Assistance' button. For testing, I will change the user id and sysdate fields from hidden to textbox.

  • Mike Kutz
    Mike Kutz Member Posts: 6,199 Silver Crown

    We need the workspace name and the info for a developer account in order for us to take a look at what might be going on within the page.

    MK

  • idm731
    idm731 Member Posts: 361
    edited Apr 11, 2014 3:52PM

    Do you want me to post the developer's creds here?

    Can you please email me at abhi2807 at hotmail dot com so that I can send you the developer's credentials. Thanks for your help.

  • idm731
    idm731 Member Posts: 361
    Answer ✓

    The issue is resolved now. I noticed that adding the default values for the form fields added duplicate processes. That is why the form was processed thrice. Removing the additional processes resolved the issue.

This discussion has been closed.