Skip to Main Content

Breadcrumb

Question and Answer

Bobby Curtis

Thanks for the question, Kishore.

Asked: January 18, 2018 - 12:56 am UTC

Last updated: April 06, 2018 - 3:48 am UTC

Version: 12c

Viewed 1000+ times

You Asked

We have a situation where the golden gate is used to replicate the source data into target ( both source and target are oracle 12c). on the target we have a column ( Target Timestamp) , primarily to track the date/time the a row is replicated. this timestamp field has a mapping within Golden Gate configuration ( Replication side) to capture the date/time. Currently this is being mapped with @DATENOW(). It appears that this function doesn't return million seconds levels. so we are actually using Target Timestamp columns for data ordering to determine the latest snapshot on a row. but as the data being replicated so quickly, it actually requires million second precision.
I was wondering, Is there any option in Golden Gate that can provide millisecond precision (as oppose to @DATENOW() )?

Appreciate any help on this.

Thanks

and we said...

The @DATENOW() function is returning the results of SYSDATE from the database. For many types items, this should be enough to meet the needs of the end user. In this case, you are wanting to dig a bit deeper and get the millisecond precision of the timestamp. Doing a simple test, this can be achieved.

The use case I used is as follows:

Source Table:

Name Null? Type
---- ----- -------------
ID NUMBER
NAME VARCHAR2(128)

Target Table:

Name Null? Type
------------ ----- ---------------------------
ID NUMBER
NAME VARCHAR2(128)
REC_DATE TIMESTAMP(6)
REC_DATE_WTZ TIMESTAMP(6) WITH TIME ZONE

These tables are the same table; just on the target side, I have two columns that record the record date (@DATENOW()) and record date with timezone. The latter allows for the milliseconds to the 6th place to be captured.

Now for the GoldenGate setup.

Extract Parameter File (Source):

extract IEXTTEST
useridalias SGGATE domain OracleGoldenGate
exttrail za
sourcecatalog pdb1;
table test.test_date;

Replicat Parameter File (Target):

replicat IREPTEST
useridalias TGGATE domain OracleGoldenGate
map pdb1.test.test_date, target test.test_date,
sqlexec (ID lookup, QUERY 'select systimestamp from dual'),
colmap(usedefaults,
rec_date = @DATENOW(),
rec_date_wtz = lookup.systimestamp
);

The changes that needed to be made in order to capture the timestamp to milliseconds required the use of SQLEXEC to call the system timestamp (SYSTIMESTAMP) from the database. Then the target table had to accept the SYSTIMESTAMP data into a datatype that supported capturing milliseconds (TIMESTAMP WITH TIME ZONE).

Now when I replicat a few transactions from source-to-target, I can see the difference between the @DATENOW() function calling SYSDATE and using SYSTIMESTAMP to get the milliseconds for when the record was applied.

ID NAME REC_DATE REC_DATE_WTZ
---------- --------------- ------------------------------- --------------------------------------
1 SysAdmin 22-JAN-18 09.44.46.000000000 PM 22-JAN-18 09.44.46.531189000 PM -05:00
2 SysAdmin 22-JAN-18 09.44.46.000000000 PM 22-JAN-18 09.44.46.703136000 PM -05:00
3 SysAdmin 22-JAN-18 09.44.46.000000000 PM 22-JAN-18 09.44.46.721737000 PM -05:00

This example provides a bit more information in terms of timezone details, but it should provide enough information to show how to use SQLEXEC to get additional information from database.



Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, January 23, 2018 - 4:00 am UTC


How about a column level DEFAULTS ?

Rajeshwaran, Jeyabal, January 23, 2018 - 6:54 am UTC

Target Table: 

Name Null? Type 
------------ ----- --------------------------- 
ID NUMBER 
NAME VARCHAR2(128) 
REC_DATE TIMESTAMP(6) 
REC_DATE_WTZ TIMESTAMP(6) WITH TIME ZONE 



won't that be good to have SYSTIMESTAMP defaulted at this column REC_DATE in the target database?

rather than making calls to "sqlexec" on the replicate parameter files to manipulate this field?
Bobby Curtis
April 06, 2018 - 3:48 am UTC

Yes, using column level defaults work as well in the solution.

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database