ORA-01403: no data found in automatic row fetch - oracle

I have an APEX page with a button that opens a modal dialog page for creating new record. When a link clicked on an interactive report, the record clicked is loaded on the modal dialog page. On that page I can either edit existing record or create a new one. When editing current record, a primary key is passed in and when creating a new records, it is not.
On the modal dialog page I have an automatic row fetch. I started getting ORA-01403: no data found error because the row fetch does not return any records (obviously, because no record exists when the "create new" button is clicked). My question is how can I avoid getting the error in the fetch when primary key is null.

How about modifying the process by setting its "Server side condition"? Its type would be Item is NOT NULL, and you'd set the primary key item as the item.

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.

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.

Oracle Apex - When I submit the data in a page item to a table in the database, why is the data in the page item disappearing?

I am currently working in Oracle Apex version 5.1.2.
I have four page items on a page in my application. One is a date picker, two are text fields, and one is for the ROWID of the table in the database. The type of the ROWID page item is "Hidden", and the ROWID is the primary key column in the table. Each page item has a "Source" of one of the columns in a single table I created in the database (it's the same table for each page item). I set this source in the Settings for each page item.
I have also created a button for the page. In the "Behavior" section of the settings for this button I have set the "Action" to "Submit Page" and the "Database Action" to "SQL INSERT action".
I have also created a "Process" for my page. The type of the process is "Automatic Row Processing (DML)". In the settings for this process, I have set the "Table Name" as the table that contains the columns I mentioned above, the "Primary Key Column" as "ROWID", and the "Primary Key Item" as "P31_ROWID", which is the name of the page item that has a "Source" of the ROWID in the table. I have set the "Supported Operations" for this process as Insert, Update, and Delete.
The problem: When I run the page and enter in data for the three page items and then press the "Submit Page" button I created, a new line item is added to the table in the database that contains the correct data that I entered into the page items. That works perfectly. However, when I press that "Submit Page" button, the data that I entered into the three page items disappears from the page items. So the data is added to the table in the database correctly, but the data disappears from the page items.
I would like for the data to remain in the page items after I press the "Submit Page" button. Does anyone know if/how I can achieve this?
Thank you in advance.
Make sure, you have in Item attribute Source set Used as "Only when current value in session state is null"
Regard

Popup form with validation and table in jsf2 and RichFaces

I have a problem with JSF2, and RichFaces ajax, Popup I have two, one in which I display a table with data and another that appears when I want to insert a new data by clicking on a button ... but I have a problem . In fact, before the data is inserted into the table I would like to check that this is not already present, if it is I have to display an error message, otherwise close the Popup used to enter the data and display the table which is located in Popup previous year, as I proceed? you can give me an example :)

cannnot able to perform update on navigation in wp7

i want to Create a Simple Database in wp7.In Mainpage i simply add the Records in database and i have another button view which is used to navigate to another page where gridview control is there that can display the data from database that is already done.In the second page i have two Buttons delete and update and i have a textbox where user can enter the id and based on that id the delete and update process can be done.i done the delete operation but i don't know how to update the selected id because onclicking the update button
it should navigate to main page and their corresponding values have to be filled in respective fields.when i tried to use onnavigated method to get the selected id record and if the page loads during startup it throws exception "no key was found"
in the line
var n = PhoneApplicationService.Current.State ["list"];
how to make the application to load so that it does not consider the key.please help me to solve this problem.Thanks
Just check to see if the key exists first:
if (PhoneApplicationService.Current.State.ContainsKey("list") == true)
{
n = PhoneApplicationService.Current.State["list"];
PhoneApplicationService.Current.State.Remove("list");
}
before trying to load it.

Resources