问题
I am using Oracle APEX to build a interactive report. In the create page I want to inert a field called create_time in the database which is not shown on the create page. Similarly, in the edit page, I want to update a field called update_time in the database.
For the edit page, I added a process and set the plsql code to:
update table_test t set t.UPDATE_DATE = sysdate
where t.ROWID = :P2_ROWID;
And this works.
However, when it comes to the create page, I set the plsql code to:
update table_test t set t.CREATE_DATE = sysdate
where t.PROJECT_ID= :P3_PROJECT_ID;
This didn't work. Then I hardcoded the where clause to sth like this: where t.PROJECT_ID='100', and I create a project with id = 100, and it works! So I suppose, for some reason this :P3_PROJECT_ID failed to fetch the value. Anyone knows why? And is there any other ways to insert create_time other than using process? Thanks!
回答1:
The reason is that APEX does not know the value of :P3_PROJECT_ID unless your process uses ID as the PK and returns the PK value.
A far easier way for both Create / Update columns is so create a DB Trigger on the table which fires whenever a record is inserted / updated , including from SQL Workshop or outside APEX all together. Install one of the Sample Apps and look at the triggers on the tables for best practices.
来源:https://stackoverflow.com/questions/39276122/failed-to-create-creation-time-in-apex-report