I have a Tabular Form in my Oracle Apex application. There is a column as UPDATED_DATE. I have set Tabular Form Attributes of this column as below.
When i'm inserting data, UPDATED_DATE column in database table is filling with a value. But when i'm updating existing record, UPDATED_DATE column is not filling with a new value. old date is remaining without changing to a newer data.
How can i solve this ?
The default will only set a value if the field is empty. On your first entry the field is empty, and therefore the updated_Date is set. On updating, the field is allready set, and therefore won't be updated.
You need to create a dynamic action (assuming you use apex 4 or above) and use that to update the date field. Your dynamic action should be triggerd on change of an table row and subsequently set the date field to the current date.
Let me now if you need help on the dynamic action.
Related
I am trying to generate a unique ID on Oracle Apex Forms field while Enter/Tab button is pressed like we do in Oracle Forms using the Key-Next-Item And Post-Change triggers on a field.
This is not Forms, this is Apex.
Basically, you shouldn't allow users to modify such an item (keep it hidden or display only).
In Apex, we usually create a process which sets the primary key item's value, such as
:P1_PK_ITEM := NVL(:P1_PK_ITEM, sequence_name.nextval);
Or, set that item's default value to fetch sequence's next value.
Or, create a database trigger which will populate column value before insert.
Or, if your database version is high enough (12c and later), create an identity column.
I have one field on my form (field example name "completion_date"). This data is stored to table column "completion_date". When users edits the detail, data is overwritten in the backend table field as a default way of storing the data. How can I pass on the existing data in this column to a new column (completion_date_a) when the user saves a new date in the field.
One option is to create a database trigger, e.g.
create or replace trigger trg_bu_date
before update on your_table
for each row
begin
:new.completion_date_a := :old.completion_date;
end;
/
Littlefoots' answer is correct, but you could also do this in apex with very little work. Suppose your form items are P1_COMPLETION_DATE and P1_COMPLETION_DATE_A, both mapped to their respective database column. P1_COMPLETION_DATE_A is hidden. Add a computation to P1_COMPLETION_DATE_A with point "After Header" and type "Item". Pick P1_COMPLETION_DATE as item.
Now when you save the form, the value of P1_COMPLETION_DATE_A will be set to the value of P1_COMPLETION_DATE when it was selected.
How can I identify in oracle forms the difference between a record obtained from the database and one just newly inserted ?
I need to requery after a button click if the record is queried before and if it is a newly inserted record then I only need to query the new record, because a requery won't contain the new record or if no query happened before then a requery will do a full query.
I tried with :system.record_status, but after commit it also contains QUERY
Exactly; after commit & requery, all records are equal and their status is QUERY.
I don't think you can do that, unless you mark newly added rows, somehow (e.g. by adding a timestamp so all rows with the MAX(timestamp) value are considered to be new).
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
I have a default value in Database. When I was inserting a new record, that time I need to avoid the default value column in the entity.
For Example:
CreatedDate Default value in database
but in my UI I need to avoid the column CreatedDate for Inserting time