Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Storing and retrieving versions in tables

158699Oct 10 2002 — edited Sep 19 2007
Hello,
I have a problem with storing different versions of data in the same table.

Eg: Consider the table

TABLE_A which has the following columns.

COL1 varchar(5);
VERSION_DATE date;
COL2 varchar (10);
COL3 NUMBER(10);

Now I have to load this table with data from a flat file. The problem is that
this flat file has different versions. For eg: let us call the flat file for
the above table as TABLE_A.TXT

Currently I parse TABLE_A.TXT with say version1 and insert into TABLE_A.
For TABLE_A.TXT version 2 I again insert all records into TABLE_A but now with
a different version date.

So now when selecting data I can specify which version I want to deal with.

But the problem is that about 80-90 % of the data in TABLE_A.TXT version 2 is
similar to version 1. I do not want to waste space inserting duplicates.

I can check when inserting data from version 2 to see if the data is the same.
If same I will not insert the row with the different version date.

But now the problem is how do I deal with the data in my select clauses especially
when I join this table with other tables which also have versioned data?

Currently I can say (since I insert all the records from TABLE_A.TXT version 2)

select * from table_a, table_b
where a.col1 = b.col1
and a.version_date = version1
and b.version_date = version2

and so I work on version 1 data from table_a and version2 data from table_b

If I avoid duplicates and only insert data that has changed how do I specify the
above query and many other queries which deal with version numbers?

Thanks a lot.

Ranga
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2007
Added on Oct 10 2002
2 comments
303 views