Oracle APEX update Master column in Detail Interactive Grid - oracle

I want to update the master column in my detail IG but I can't. When the page submits the old value returns. All the other columns updates as expected.
Any suggestions?

Basically, you want to move detail row to another parent, right?
It seems that you can't do that in a master-detail form because that column is used to enforce referential integrity; in detail block, its "Master column" property is set to master region's primary key column.
Initially, detail primary key item is hidden. It means that it is always inherited from the selected master record. If you add a new row, it'll belong to that master. So, if you unhide it (and set it to e.g. text item) so that you'd be able to update its value, processing "reverts" your changes and sets the detail region primary key value to the same selected master's primary key value.
What to do? Create another page which will be based on detail table, then there won't be any restrictions of that kind (i.e. you'll be able to change the primary key column to point to another master).

Related

Modal Dialog Form Primary Key item not refreshing in Parent Page

I am beginner in Oracle APEX (Version 22.11) and I hope, that someone can help me:
I have an Interactive Report as Parent Page. I get the data with a (simple) sql query. There is also a Create-Button, which works fine. It opens an empty Modal Dialog Form, where I can fill in the entries. There is a dynamic action, which refresh this Interactive Report by Closing Dialog.
On another page I have this Modal Dialog Form, which use the same sql query as the Parent Page and have the four button 'Cancel','Delete','Save' and 'Create'. I choose also a primary key and do different setting:
under 'Processing' I make Form - Automatic Row Processing(DML) and also Yes to 'Return Primary Key(s) after Insert
for the 'Save'-Button I have the following Behavior:
Action: Submit Page
Database Action: SQL UPDATE action
Also I have for this button the following Server-side Condition:
Type: Item is NOT NULL
Item: [Item of the primary key]
Now, I have the following problem with this Save-Button (the other buttons works fine): When I edit the Radio Button or the Textfield in this Modal Dialog Form and click the Save-Button, the Parent Page takes over the changes. But when I change the Textfield of the primary key Item or when I change another Textfield or a Radio Button together with this Primary-Key-Textfield, the Parent Page doesn't take over the changes.
Where is the mistake? Can anyone help me?
I think what happens is something else than what you think is happening. As a test I created an interactive report with a form on the EMP sample table (you can generate that in SQL Workshop > Utilities > Sample Datasets). Out of the box the report refreshes when a change in the modal form is submitted. In the modal form P102_EMPNO is marked as primary key.
No what does that mean ? It means that that page item is used by the apex engine to uniquely define the row when executing dml (update/delete) on that row.
I changed the page item P103_EMPNO to a text field, enabled debug and submitted the form. This is what debug shows:
As you can see, the where clause of the update statement is:
where "EMPNO"=:APEX$PK1
I'm assuming the bind variable :APEX$PK1 is what the apex engine has decided is the bind variable for the (first) primary key column in the form.
So... if you change the primary key, then it is NOT going to update the primary key for that row. Instead it is going to try to update a row that has the newly entered primary key value. And the refresh you're expecting is not happening... because no rows were updated.
The reason is that primary keys should never be changed during normal operation in a relational database. They uniquely define the rows - that is what a primary key does. The form region is based on this principle and the behaviour that you're seeing is expected. Also, the reason that the primary key page item is hidden or display only when a form is created is that a primary shouldn't be changed.
Now if you really want to change the primary key value (my advice: DONT. EVER.) then you can probably create a form yourself and use the rowid to identify the row. Out of the box the form region does not let you select the row id.

How do I change the selected item label in a Dataverse Form lookup?

In a dataverse table I use autonumber as the primary name column. When I add existing rows (n:n relation) using a subgrid, a search pane is displayed on the right side of the screen. The quicklist shows up correctly, but it doesn't make sense displaying in the list of selected items.
How/where do I change this?
Typically the grid/list/card will show the first three fields of lookup view designed for that entity while searching/associating. You have that luxury to rearrange the fields to display including name, auto number and other fields.
Lookup display field is designed to show the Name field of that entity record by default (only choice). Since you are using auto number type for that Name field, it’s showing only auto number - this is expected.
Normally we will have a separate auto number field and concatenate few fields along with auto number to the Name field to make sense. But you chose the other way.

How to enable interactive grid cell validation in Oracle Apex Master-Detail page?

I have created a Master-Detail page in my Oracle APEX application. Basically i have a list of rows from one table and I can add values to it though a form. That works correctly, validations also work (every column from Master form can be accessed by adding ":" in front and that works in this case). I also have an option to edit click pencil icon in front of every row which lets me to update current row and also displays the Detail part of that row. Detail part is a list of values from another table that is connected to the first one using foreign key (Master-Detail: one to many). It is automatically displayed as interactive grid, so when editing my Master table value I can also add new rows to Detail table, but the validations don't work for Detail table. I tried accessing it's columns the same way as before, but it just doesn't work (tried to add PL/SQL expression validation:
:column >= 0
but that didn't work. How can I enable the validation for interactive grid, because I've looked into some resources about it, but they just show the first way, that doesn't work for me?
For a validation on an Interactive Grid you need to set the attribute "Editable Region" for the validation to your interactive grid. That works ok for me. I tried with a Master Detail on Dept (Master) and Emp (Detail) with a validation on detail of :SAL > 1000

APEX Primary Key Column Replaced by Edit

I currently have a master detail form within my APEX application which should show two columns, one of which should be the primary key.
However, it appears that my primary key column has been replaced with the "edit" button/column, which I also want to keep. When I try and edit the attributes for the primary key column, changing the "display as" option appears to have no effect, and the edit button remains.
Currently my form looks like this:
And the column attributes look like this:
And ideally, I would like an additional column to this, but with the primary key values after the edit button.
I imagine there's something very simple which I'm missing!
The edit link properties come from attributes within the column. If you click on the pencil in your second image, that will show column attributes. Look for "Action" attributes that describe the link to another page. The "Link Text" will be referencing the edit icon. You could replace this with #COPYID# to show the primary key value as a link. Or you could add another column "copyid as copyid_dsp" to show both.

What's the best way to control a NSTableView's selection using checkboxes?

For some user interfaces it makes sense to have explicit checkboxes to allow users to select the items in a table. What's the best way to accomplish this using cocoa? In other words, how can I link the state of a checkbox in each row to whether or not the row is currently selected?
Tony,
if I get you correctly, you want to add a leading column to your NSTableView so you can select the corresponding column(s), separate from the usual selection of the tableView.
What is your datasource of the table view? A core data stuff or an array/dictionary? if you do not want to modify your data model, you could set up a distinct array (mutable), to keep track of the selection. bind it to the checkbox column (you would want to add as first column) and keep the array in sync with the number of items in the general datasource for the table that displays your valuable data.
You could also enhance your data model with a column "selected", make it BOOL and bind it to the checkboxes. This would also allow you to easily save the last selection to you database or file, whatever you are using.
Can you update your question with some more information on your data model?
sya - living.

Resources