Search code examples
oracleoracle-apexlov

session item does not change when using lov in primary key


I am implementing a Interactive grid to perform DML operations on a table.

it has combined primary key of two columns One primary key column is display only and refer to master table and another primary key column I want to have a LOV to select value. LOV is dynamic lov having a display and return value picked from another table.

Inserts are fine but session state item value is set for one row and all the operations are performed on that same row irrespective of which row is selected.

you can see a sample here https://apex.oracle.com/pls/apex/f?p=128616:2:1964277347439::NO:::

master table name: sample detail table name: sample_child

primary key in sample child : ID and Name pop lov is implemented in NAME LOV values are picked from table: Sample_uncle LOV display : ID || '-' || NAME LOV return : ID

you can try to update blabla column of sample_child table to see the issue.

I am not sure how I can give you access to look at the implementation.

I have already tried all the options I can think of


Solution

  • This is to do with your primary keys, the detail table does not appear to have proper ones, thats why it always tried to update the first entry, and I think this is also why every row is marked when you load the table.

    Primary keys also do the annoying thing of refusing to be empty, as you can see if you insert a new row, the middle column(which is a PK) is filled with 't1001'.

    Since you are dealing with simple tables(and not a whole bunch of joined tables) I always consider it best to use ROWID as PK. So set ROWID as PK for the master table, and ROWID for the detail table. And have the detail table have a Master table be your master table, and then click on the first column in the detail table and set the master column for it. And I also personaly always hide the column that is linked.

    I would advise you use ROWID whenever possible as its just so much easier to work with, it does mean you might need to set up a validation to prevent someone adding duplicated values for your actual PK, but since the PK is in the underlying table, they cant enter it anyways(but if you have a validation, the error will be much prettier), whilst if the column is a PK, APEX will prevent duplicates by default.

    I hope this helps