Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> SQL Query Question
I am a SQL novice, I know enough to do fairly simple things but I'm
not sure that I always take full advantage of the power of SQL to
solve problems. I currently have a problem that I think I could solve
with some simple SQL command but I'm not sure how to go about it. The
problem is this, I have a table in an Oracle database which contains
information about key customers. Information about customers is
collected by an outside source. The outside source provides me a
table of customers where each customer is identified by a numeric key.
However, there are two types of key which may be used to identify the
customer. Either key (or both) may be specified. In the end, I get
information of the form:
Key1 Key2 Customer Attributes ------------------------------------------------------------ 111111 Foobar 111112 A-100 Barfoo A-101 MooBar
When I get the information, I put it in a table and assign each record a unique id. In the example above, I would assign the ids 1, 2, 3 to the records.
Periodically, I receive new new updates. When these updates come out, customer information is updated. It's possible that where a Key1 wasn't specified there may be a Key1. Where a Key2 wasn't specified, there may be a Key2, there may be new entries, and some existing entries may have been deleted. What I need to be able to do is merge the new data with the old. Wherever I find a matching Key1, or Key2 I want to replace all data with the new data, but I want to keep my assigned identifier. Wherever there are new records, I want to assign a new unique identifier to the record. Finally, I would like to produce a list of all records which have been deleted.
Any tips on a straight-forward way to do this would be appreciated. I
Thanks.
James W. Howe Voice: (734) 669-2244 AppNet Inc. 650 Avis Dr. Suite 100 mailto:jhowe_at_appnet.net Ann Arbor, MI 48108 http://www.appnet.netReceived on Wed Aug 04 1999 - 09:00:13 CDT
![]() |
![]() |