You are on page 1of 6

How Date Track Works [ID 177733.1] DateTrack adds the dimension of time to an application's database.

The value of a DateTracked record depends on the date from which you are viewing the data. For example, querying an employee's annual salary with an effective date of !"#$%" &&! might give a different value than a query with an effective date of ' "D()" &&!. *owever, the application and the user see the employee's pay as a single record.

Behavior of DateTracked Forms


+hen you begin to update or delete a record on a DateTracked form, you are prompted with a number of choices. This section describes the choices and their effect on the DateTracked table. The term ,today, refers to the effective date set by the user.

Update
+hen a user first alters a field in a DateTracked block in the current )ommit unit, he or she sees a choice of $pdate prompts as followso $.D/T( " $pdated values are written to the database as a new row, effective from today until 0 "D()"12 !. The old values remain effective up to and including yesterday. o )344()T536 " The updated values override the old record values and inherit the same effective dates.

5f the user selects $.D/T(, DateTrack checks whether the record being updated starts today. 5f it does, a message warns that the previous values will be lost 7because DateTrack can only store information on a day by day basis8. DateTrack then changes the mode for that record to )344()T536. 6ext, if $.D/T( was selected, DateTrack checks whether the record being updated has already had future updates entered. 5f it has been updated in the future, the user is further prompted for the type of update, as followso $.D/T(9)*/6:(956;(4T 75nsert8 " The changes that the user makes remain in effect until the effective end date of the current record. /t that point the future scheduled changes take effect. $.D/T(93<(445D( 74eplace8 " The user's changes take effect from now until the end date of the last record in the future. /ll future dated changes are deleted.

5n most forms, users are prompted for the update mode for each record they update. 5n some forms, they are asked for the update mode for only the first record they update. /ny other rows updated take the same update mode. $sers are not prompted again, until they have committed or cleared any outstanding changes.

De ete
+hen deleting a record, the user is prompted for the type of delete. There are four options, as followso D(%(T( 7(nd Date8 " This is the DateTracked delete. The record that the user is currently viewing has its effective end date set to today's date. The record disappears from the form although the user can requery it. o =/. 7.urge8 " This is the total delete. /ll records matching the key value, whatever their date stamps, are deleted. F$T$4( )*/6:( 7/ll8 " This choice causes any future dated changes to the current record, including a future DateTracked delete, to be removed. The current record has its effective end date set to 0 "D()"12 !. The record can again be displayed by requerying. D(%(T( 6(>T )*/6:( 76ext )hange8 " This choice causes the next change to the current DateTracked record to be removed. +here another future dated DateTracked row exists for this record, it is removed and the current row has its effective end date set to the effective end date of the deleted row. +here no future DateTracked row exists, but the current row has an end date other than 0 "D()"12 !, then this option causes the effective end date to be set to 0 "D()"12 !. This means that a date effective end is considered to be a change. 6otice that this option again removes the current row from the form, though it can be displayed again by requerying.

I!sert
The user is not prompted for any modes when inserting a record. The effective start date is always set to today 7(ffective Date8. The effective end date is set as late as possible. $sually this is 0 "D()"12 !, although it can be earlier especially when the record has a parent DateTracked record.

Ta" e #tr$ct$re for DateTracked Ta" es


/ DateTracked 7DT8 record is what the application and the user see- a single DT record for each key value. *owever, this DT record may change over time, so it may correspond to one or more physical rows in the database. The history for the record is held by storing a row when the record is created, and an extra row every time the record changes. To control these rows, every DateTracked table must include these columns(FF()T5<(9;T/4T9D/T( D/T( 63T 6$%% (FF()T5<(9(6D9D/T( D/T( 63T 6$%% The effective start date indicates when the record was inserted. The effective end date indicates when the record was deleted or updated. / deleted record has the highest end date of all the rows with that key, but for an updated record there will be at least one row for this key with a higher effective end date.

/s time support is not provided, the effective start date commences at '''' hours and the effective end date finishes at !0?& hours. This means that a DT record can change at most once per day.

%&amp e
%'(ID %'()*'% #*+*,- %FF%.TI/%0#T*,T0D*T% %FF%.TI/%0%)D0D*T% 0!'0 0!'0 0!'0 ;@5T* ;@5T* ;@5T* 2,''' A,!'' A,1'' !"@/4" &A& !'"#$%" &A& ! "#$%" &A& &"#$%" &A& !'"#$%" &A& ' "D()" &A&

%&amp e of DateTracked Ta" e .o!te!ts The table above shows the physical table after the user has done the followingo ;et the effective date to !"@/4" &A&. 5nserted record for ;@5T*. o o o ;et the effective date to !'"#$%" &A&. $pdated ;@5T* record with new salary. ;et the effective date to ! "#$%" &A&. /gain updated ;@5T* record with new salary. ;et the effective date to "D()" &A&. Deleted record for ;@5T*.

The table below shows what the user sees on querying the ;@5T* record at different effective dates. %FF%.TI/% D*T% "@/4" &A& !"#$6" &A& ! "#$%" &A& '!"D()" &A& %'(ID BB no rows retrieved 0!'0 0!'0 BB no rows retrieved ;@5T* ;@5T* 2,''' A,1'' %'()*'% #*+*,-

%&amp e of 1$er2 ,es$ ts for a DateTracked Ta" e Cecause the primary key column in the table is no longer unique, any indexes on the table that included the primary key column must now also include the (FF()T5<(9;T/4T9D/T( and (FF()T5<(9(6D9D/T( columns.

+ist of DateTracked Ta" es


To get a list of the DateTracked tables used in 3racle *uman 4esources, select from the data dictionary where the table name is like /pplication ;hort 6ameDF. ;ubstitute in the *4@; application short code you are interested in 7such as .(4 or C(68. For each of the DateTracked tables there is a DateTracked view called ET/C%( 6/@(F and a synonym pointing to the full table called ET/C%( 6/@(9FF.

.reati!3 a DateTracked Ta" e a!d /iew

The previous section described the table structure of a DateTracked table. This section describes the steps to go through to create a DateTracked table and view. Gou must use the following nomenclature for DateTracked tablesCase table- ET/C%( 6/@(9FF DateTracked view- ET/C%( 6/@(F 5n addition to the DateTracked view, there is another view that shows the rows in the table as of ;G;D/T(. The name of this view is derived by replacing the 9F at the end of the table name by 9>.

%&amp e
To incorporate DateTrack on to an existing table called (@.%3G((;, follow these steps. )reate a new table called (@.%3G((;9F that is identical to (@.%3G((; but with the columns (FF()T5<(9;T/4T9D/T( and (FF()T5<(9(6D9D/T( added. 6ormally you would set the (FF()T5<(9;T/4T9D/T( and (FF()T5<(9(6D9D/T( columns to the maximum range. CREATE TABLE EMPLOYEES_F AS SELECT EMPLOYEES.*, TO_DATE('01-01-0001','DD-MON-YYYY') EFFECTIVE_START_DATE, TO_DATE('31-12- !12','DD-MON-YYYY') EFFECTIVE_END_DATE FROM EMPLOYEES" ALTER TABLE EMPLOYEES_F MODIFY (EFFECTIVE_START_DATE NOT N#LL, EFFECTIVE_END_DATE NOT N#LL)" 4emove the old table. DROP TABLE EMPLOYEES 5f the old table already has the two new columns, Hust rename it. RENAME EMPLOYEES TO EMPLOYEES_F" !. )reate the 6ew $nique 5ndexes of the DateTracked Table by dropping the old indexes, creating the new unique indexes as old unique index I (FF()T5<(9;T/4T9D/T( I (FF()T5<(9(6D9D/T(, and creating the new non"unique indexes the same as the old non" unique indexes. 0. )reate a DateTracked view called (@.%3G((;. This view uses the entry in F6D9;(;;536; for the current user effective id for the effective date. CREATE VIE$ EMPLOYEES AS SELECT * FROM EMPLOYEES_F $%ERE EFFECTIVE_START_DATE &' (SELECT EFFECTIVE_DATE FROM FND_SESSIONS $%ERE FND_SESSIONS.SESSION_ID ' #SERENV('SESSIONID')) AND EFFECTIVE_END_DATE (' (SELECT EFFECTIVE_DATE FROM FND_SESSIONS $%ERE FND_SESSIONS.SESSION_ID ' #SERENV('SESSIONID')) 1. To create the view (@.%3G((;9> based on the table (@.%3G((;9F, use the following ;J%CREATE VIE$ EMPLOYEES_) AS SELECT * FROM EMPLOYEES_F $%ERE EFFECTIVE_START_DATE &' SYSDATE AND EFFECTIVE_END_DATE (' SYSDATE

,estricti!3 Datetrack 4ptio!s *vai a" e to Forms Users


+hen a user edits or deletes a datetracked record, the system displays a window asking the user what type of update or deletion to perfom. Cefore it displays this window, the system calls a custom library event 7called DT9;(%()T9@3D(8. 5t passes in the list of buttons that DateTrack would normally display 7such as $pdate and )orrection8. Gour custom code can restrict the buttons displayed. 5f necessary, it can require that the user is given no update or delete options, and receives an error message instead. *owever, it cannot display buttons that DateTrack would not normally display for the entity, effective date, and operation the user is performing. 5f the user chooses $pdate and future changes exist, the custom library event point may be executed a second time so your custom code can determine whether the user is given the two update options- 5nsert and 4eplace.

5 o"a /aria" es
The following global variables can be used at the DT9;(%()T9@3D( event. They are not available at any other )$;T3@ library event. 5 o"a /aria" e )ame g9dt9update ,ead6Write 4ead and write 4ead and write Descriptio! ;et to T4$( when the product would normally display the $pdate button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the )orrection button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the 5nsert button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the 4eplace button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the .urge button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the (nd Date button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the /ll button on the mode selection window. 3therwise set to F/%;(. ;et to T4$( when the product would normally display the 6ext button on the mode selection window. 3therwise set to F/%;(.

g9dt9correction

g9dt9update9change9insert 4ead and write g9dt9update9override 4ead and write 4ead and write 4ead and write 4ead and write 4ead and write

g9dt9Kap

g9dt9delete

g9dt9future9change

g9dt9delete9next9change

5 o"a /aria" es at DT0#%+%.T0'4D% %ve!t

*tte!tio!7 )ustom code can change a T4$( value to F/%;(. *owever, if it tries to change a F/%;( value to T4$(, the system ignores this change.

%!a" i!3 the DT0#%+%.T0'4D% %ve!t


To enable the DT9;(%()T9@3D( event, add the following code to the ;TG%( procedure in the )$;T3@ package, )$;T3@ library*+ ,-,./_.01, ' 'DT_SELECT_MODE' /2,. 3,/43. 546/o1.0+/,3" ,76, 3,/43. 546/o1.6/0.8038" ,.8 *+"

%&amp e .$stom .ode


;uppose you wanted to stop the Delete mode button from being displayed on the @ode ;election window when DateTrack would normally make it available. Gou could add the following code to the (<(6T procedure in the )$;T3@ package, )$;T3@ library*+ (,-,./_.01, ' 'DT_SELECT_MODE') /2,. *+ .01,_*.('9LOBAL.9_DT_DELETE') ' 'TR#E' /2,. 5o:;('FALSE', '9LOBAL.9_DT_DELETE')" ,.8 *+" ,.8 *+"

You might also like