Home » SQL & PL/SQL » SQL & PL/SQL » utility which selectively updates/inserts a record for given fields
utility which selectively updates/inserts a record for given fields [message #37995] |
Wed, 13 March 2002 00:39 |
gnana
Messages: 1 Registered: March 2002
|
Junior Member |
|
|
There are 2 databases DB1 and DB2.
There is a table temp1 in DB1 as well as in DB2 with fields as
field_key (primary key) (char(2))
field_1 (char(1))
field_2 (char(2))
field_3 (char(3))
field_4 (char (4))
There are some records in the table temp1 in both the databases (DB1 and DB2).
Some of the records (as far as primary key is concerned) are duplicates in DB1 and DB2 databases.
I want all the records of this table to be inserted from DB1 to DB2 such that if the record corresponding to the primary key field(field_key) in DB1 is not there in DB2, then the record be directly inserted to DB2 else for this duplicate record the field values for the fields (field_3 and field_4) be updated in DB2 corresponding to that record.
Just for an example, suppose the table temp1 has rown in DB1 as
AA, N, Y, X, Z
AB, N, N, C, Z
AC, Y, N, Z, X
DD, L, S, Q, R
and in DB2 , the rows are
AB, N, N, C, D
BC, Y, N, M, L
DD, K, Q, N, N
then the final temp1 in DB2 should have the following rows::
AA, N, Y, X, Z
AB, N, N, C, Z
AC, Y, N, Z, X
BC, Y, N, M, L
DD, K, Q, Q, R
(Note that in the final result, the values corresponding to the rows AB, DD for the fields field_3 and field_4 has been taken from DB1 database)
I know the above can be done using PL/SQL. But, I would like to know if there is any ORACLE utility which can be directly used to perform this activity(i.e a utility which selectively updates/inserts a record for given fields)
|
|
|
|
Goto Forum:
Current Time: Sun Jun 30 00:41:30 CDT 2024
|