0

We have an existing system, where data is imported from file. We have a procedure which imports data from file to data_table. File have a unique column with TID, if this TID exists in data_table it simply updates else inserts a new record into data_table. For this each activity (insert/update) we are inserting value into other tables called track_table which inserts new row into this table for each activity. Meaning if data_table table is updated/inserted it will create new record into track_table for tracking purpose.

track_table looks like. Id, DATE, TID, TEXT

Here, we have multiple same TID's for each activity. Id column is for identifying record uniquely. Now, we are looking to prevent inserting every time into track_table if record in data_table already exists.

I believe we can also do this by comparing each field into file with filed in table, but would be glad to know for some other solution.

Looking for your suggestions. Thank you.

Thom A
  • 88,727
  • 11
  • 45
  • 75
Ruchita P
  • 359
  • 1
  • 4
  • 17
  • Yuo could use a trigger in data_table, that only inserts into track_table if a column value gets changed by the update statement to data_table. – SAS Jan 19 '18 at 09:58
  • 1
    [SQL Server](https://learn.microsoft.com/en-us/sql/t-sql/language-reference) and [Oracle Database](http://docs.oracle.com/cd/E11882_01/server.112/e41084/toc.htm) are different software packages produced by different companies. Even if both of them implement SQL, they extend it in different ways and sometimes they use different syntax conventions that render the queries incompatible between them. Please use only the tags that match the software you are using. – axiac Jan 19 '18 at 10:28
  • @SAS, thanks, but any chance if we can do this in same procedure without trigger? – Ruchita P Jan 20 '18 at 07:06
  • @axiac, thanks. Will follow this practice for my next questions. – Ruchita P Jan 20 '18 at 07:08

0 Answers0