Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    4

    Unhappy Unanswered: Avoiding duplicate record error when manipulating primary key

    I have a table say TEST_TABLE with columns TEST_PK and TEST_DATA(TEST_PK being primary key).
    I make a data block in oracle forms for this table and provide the functionality in which user can manipulate the TEST_PK i.e

    State-1 of displayed data block on form

    TEST_PK
    1
    2

    State_2 of displayed data block on form

    TEST_PK
    2
    1

    Now when i commit this form i get the error which basically suggests that there are duplicate records.
    What i think is this to save the form in State_2 system tried to save '2' but in second record/row there was already a '2' due to which i got error. Am i right? If yes how can I tackle this situation??? I hope i'm able to convey the problem

  2. #2
    Join Date
    Nov 2003
    Location
    down on the cube farm, left then right then another left
    Posts
    467
    You are correct in your assessment of what is causing the error

    I am not sure if you are talking about having two blocks both displaying the record or 1. Please clarify.

    Forms is smart enough to know if you created a new record or if you are updating an old record. (that is why I question how many blocks you are using). I am wondering if you are messing around with the "set_record_property" values. Are you for some reason setting the record to be "NEW"?

    Standard Forms functionality should allow you to create a record in a block (RECORD property = NEW), save it, upate a column (RECORD property = UPDATE), and save it without error. I would suggest you start over with your form. Use the wizards and create a basic form on the table. Run it and follow the steps I outlined.

  3. #3
    Join Date
    Dec 2003
    Posts
    4
    well there is only single data block. And i've made it through the wizard. One can swap any two rows of the displayed block...

  4. #4
    Join Date
    Nov 2003
    Location
    down on the cube farm, left then right then another left
    Posts
    467
    What do you mean "one can swap any tow rows"? If you cut a row from one "line" and insert it into a another that is a NEW record to Oracle. Why are you swapping?

  5. #5
    Join Date
    Dec 2003
    Posts
    4
    by swapping i mean just changing the display order of the keys on form.

  6. #6
    Join Date
    Nov 2003
    Location
    down on the cube farm, left then right then another left
    Posts
    467
    I still do not understand if you are manual move data from box to box or just running some sort algorithm. Maybe it doesn't matter.

    after you do your move try
    set_record_property(record#, table, STATUS, QUERY_STATUS)

    you need to specify your record number and table. They can either be hard coded of you can use the SYSTEM variables. Check out your doc on the specifics of set_record_property & SYSTEM variables

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •