Oracle APEX DML form (with no report) doesn't show existing data in the table - oracle

I've been able to create APEX forms with reports and interactive grids successfully, but when I tried to just create a simple DML form, using the wizard, I get a page where I can create a row, but I can't see the existing data in the table.
This particular table always has only one row and I just need a form to update that 1 row. How can I get this view to open in update mode?

If you don't know ahead of time what any of the values in one of the columns, you can use ROWID as the primary key and set it to the row's ROWID in order to trigger the automatic row fetch process.
Create a hidden item called P1_ROWID. Its Source should be set to Database Column, ROWID.
On the Automatic Row Fetch process, set Primary Key Column to ROWID and Primary Key Item to P1_ROWID.
Create an additional process, to run before the automatic row fetch process, that executes a query like the following:
select rowid into :P1_ROWID from mytable;

Related

Populate data from DB and save as new record oracle forms

I Have populated master detail block from Data based want to change some values in data block and save it as a new record in Both master and child tables.
To Populate used execute query
Changed values as record
Save by commit
But as i used execute query to populate existing data on commit it is trying to update already saved data in table. But i want to create new records in DB with new primary key
That won't work, as you noticed. Records you fetched are database records so - once you update their values and commit, you overwrite data.
If you want to insert new records, then
add them into new rows - you can do that manually (by typing those values), or
you can duplicate one of previous records into a new record (use Forms menu for that or a shortcut key; look for "duplicate record" option) and modify that duplicated record.
Alternatively, don't use data block but control block (the one that isn't based on a database table). Populate it, somehow (e.g. you could create a button which calls the procedure; it uses a loop and populates record-by-record). Modify values you want and create your own procedure which will insert new rows into the database table. As of the primary key, it depends on how you do it; if it is a database trigger which uses a sequence, it (the trigger) will do the job. Otherwise, you'll have to create a primary key yourself (during the insert process).

Oracle Apex 20.1 Automatic DML processing not working to save updates

I have created an apex page with static content.
The details are as below:
Pre-rending-> fetch rows from P_IT_PEOPLE table with primary key person_id defined.
Region-> The columns which are to be used defined along with primary key PERSON_ID which is kept hidden.
other items-> P5_ASSIGNED_DEPT,P5_APPROVER,P5_PERSON_NAME.
Region Buttons-> SAVE/CANCEL
SAVE-> Server side-> Submit-> SQL Update action
Processing:
Create process rows of P_IT_PEOPLE
Automatic Row Fetch Legacy
Table name, primary key defined (PERSON_ID)
Supported operations-> only update selected as i just want this page to update the columns person_name, assigned_dept and approver accordingly.
Whatever fields i enter should get updated in the table.
However in app, after i click save, no updates. It is successful but neither db, nor front end, nowhere updates happen.
What am i doing wrong?
[1]: https://i.stack.imgur.com/7JpNA.png
[2]: https://i.stack.imgur.com/UjbXD.png

Oracle Form FRM-40508 Unable to insert the record

I have a Form, and I create a trigger pre-insert in the data block
select Investor_Seq.nextval into :INVESTOR.INVESTOR_NUMBER from dual;
all the data is valid,
I only use two trigger, PRE-INSERT AND WHEN BUTTON IS PRESS
press save button:
FRM-40508 Unable to insert the record
i am using the save button the trigger WHEN BUTTON IS PRESS:
commit_FORM;
it seem the PRE-INSERT statment error? but the new Investor number is show up on the text item.
ORA-01400: cannot insert NULL into ("ORCL5_10"."INVESTOR"."INVESTOR_NUMBER")
SQL statment ERROR
INSERT INTO INVESTOR (FIRST_NAME,LAST_NAME,STREET_ADDRESS,CITY,PROVINCE,POSTAL_CODE,
AREA_CODE,PHONE_NUMBER,EMAIL_ADDRESS,ACCOUNT_NUMBER)
VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10)
If you check the column list of the INSERT statement, you'll see that investor_number isn't among those columns.
It means that - although PRE-INSERT trigger fetched the next sequence value into a field on the screen, it is not part of that table. I guess that its database column property isn't correctly set, i.e. that form field doesn't belong to the investor table.
Should be easy to fix; inspect :investor.investor_number field's property palette and map it to the table column.

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
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

How to generate table scripts with data in Toad for Oracle - 9.7.2

I wanna create a script for table that should include
Create Table statement
Data in the table
Sequence in the table(Only sequence code)
And Trigger associated to it
I have added Sequence and trigger for auto increment ID, I searched but I couldn't get enough answers for Sequence in trigger.
I understand you, partially.
In order to get CREATE TABLE statement, choose that table and on right-hand side of the screen navigate to the "Script" tab - there it is. Apart from CREATE TABLE, it contains some more statements (such as ALTER TABLE in order to add constraints, CREATE INDEX and your number 4 - CREATE TRIGGER).
As of the sequence: it is a separate object, which is not related to any table. One sequence can be used to provide unique numbers for many tables, so - I'm not sure what is it that you are looking for.
In order to get data from that table, right-click table name; in menu choose "Export data" >> "Insert statements". That'll create bunch of INSERT INTO commands. That's OK if table is small; for large ones, you'll get old before it finishes.
The last sentence leads to another suggestion: why would you want to do it that way? A proper option is to export that table, using either Data Pump or the Original EXP utility.
[EDIT]
After you insert data "as is" (i.e. no changes in ID column values), disable trigger and run additional update. If we suppose that sequence name is MY_SEQ (create it the way you want it, specifying its start value etc.), it would be as simple as
update your_table set id = my_seq.nextval;
Once it is done, enable the trigger so that it fires for newly added rows.

Resources