Modal Dialog Form Primary Key item not refreshing in Parent Page - oracle

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.

Related

"Oracle Apex error: no data found" when opening a form

I have a very simple Oracle Apex app. I created a button on the home page. I also created a second page using the "Form" template, and the source for this form is a table in the local database.
I set the button to open the form, and I passed the value of the primary key of this form (it's a column called ID) from the home page to the form page, as this screenshot of the button's behavior shows (3 is the page number of the form, P3_ID is the page item in the form associated with the primary column "ID", and 1 is the value that I passed for P3_ID):
The table that the form references is empty, i.e. there is no row with ID equal to 1. Meaning I want to pass the value of 1 to this form so that it automatically create a row with ID of 1 after the user fills out the rest of the form. Here is the form page:
Now the error. When I run the app and press the button, I get this error:
The error says it's from the process called "Initialize form Warcraft Particulars". I searched everywhere and I couldn't find a process by that name anywhere in the app. What am I doing wrong?
Pre-rendering process (in a form) will try to execute query and fetch a row whose ID = 1; as it doesn't exist, Apex raises the no_data_found error. That's why you got it (the error).
Moreover, you're doing it wrong - don't pass ID you'd want to create, fill it in form's process (or use a database trigger which will put a sequence number into the ID column, or use an identity column if your Oracle database supports it (12c onward)).
Furthermore, I'd suggest a slightly different approach: don't create a form that's alone in the Universe. Approach that lets you both view existing data, update (or delete) it and insert new rows is to use a Wizard and choose a report with a form. Exact naming is different from one Apex version to another; for example, current apex.oracle.com Apex version is 22.2 and it offers "Interactive report", while the 1st Wizard page lets you choose whether you want (or not) to include a form page (you'd say "Yes").
Anyway: once you find the correct option, choose it and wizard will then create an interactive report page you'd use to
view current data
it has an edit icon at the beginning of each row which - when pressed - navigates to the form page where you can edit values or delete entire row
create new row (by pressing the "Create" button)
and a form page which does what I described a moment ago.

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

Oracle ADF : Select Check box at row level giving issue while selecting in panel tabbed

I am referring to this blog.
http://andrejusb.blogspot.in/2010/05/yes-no-check-box-in-query-criteria.html
however my requirement is different. I have multiple tabs where multiple tables are present. In each table row I need a column attribute is_active in checkbox format. So basically I want to store active or non active setup lines through panel tabbed screens.
With above blog approach first tab is working fine for checkboxes, but the second , third and other tabs are having below issues in check box.
When selected one checkbox, let's say it is checked, other checkboxes in all rows gets checked.
I checked the binding it is bind to it's respective attributes and VO iterators in pagedefinition, I chceked the code for model and view layer for working and non working tab.
Above issue is solved when created a transient attribute with control type checkbox, that transient attribute will be contolling the is_active value.

Why is my Oracle APEX DML Form stuck in edit mode and not going back to create mode?

I have created a page based on "Form & Report" template. So there is the Report page on which there is the create button. That create button leads to the form page which contains.
It is pretty simple. I don't know if there is a cache memory not emptying itself or if there is a setting that I have not properly set.
When I want to create a new database record, Oracle Apex behaves as if I asked it to update a record (though it still presents me with empty text fields).
Below the image of what's happening.
Create button of the Report
Buttons for edit are shown when I click the create button
Those edit buttons are shown instead of the buttons below => This means that the Apex software is behaving like I asked to edit a record not to insert a record.
Why is this happening?
You need to take a look at your create button. Is it passing a value to the form? If so, you probably don't want that. Is it clearing the cache of the form? If not, you probably want to clear it.
Also, on the form page take a look at your processes.. specifically the Automated Row Fetch (ARF) process.. what's the primary key that this process is using?
Also, take a look at the conditions for each button on your form. For the delete/save buttons you likely want a condition type of "value of item / column in expression 1 Is NOT NULL".
For your create button you would want the opposite.. "value of item /... IS NULL".
In both cases for the expression 1 you'd want to use the item that your ARF is leveraging.
#Bloomberg58 if you used the wizard that should not have anyway try to validate the create button in report page and the server-side validation of create and save button in form page

Oracle APEX default value not working on cascaded items

I have a blank page with a static content region (Template = Form Region). I select a project via a select list (there is only one project, so it automatically selects it). I then have a key popup lov (a popup lov that displays the description not the returned number value) from which I select a person to be in this project. I am trying to get the form to display the person I selected and saved previously when the form launches for the first time (since the project is chosen due to there being one). This works when you refresh the page, but it doesn't work if you log out and log back into the form. I tried using the default value with a sql query. I tried using a dynamic action that fires when the project changes; but neither approaches work. I fiddled with all the settings, but couldn't get anything to work. Does anyone know how to accomplish this in Oracle APEX?
I even added a refresh of the cascading popup lov to the dynamic action. I can see the hidden input item showing my defaulted value, but the popup lov does not display it on screen. Is this an Oracle bug?
Also in Javascript from the console
$s("P51_LINE_MANAGER1", "7104");
sets the hidden value, but doesn't display on screen.
$v("P51_LINE_MANAGER1");
does however return 7104.

Resources