Merge
358352Jun 15 2004 — edited Jun 16 2004Hello,
I have one temporary table that looks like:
TABLE: info_tmp
Last_name First_name Gender Room Station
--------- ---------- ------ ---- -------
Müller Karl 0 5 1
......
The column gender, room and station are foreign keys values.
And I have two table that are in relation. The table looks like:
TABLE: Patient
P_ID Last_name First_Name Gender
---- --------- ---------- ------
1 Schmidt Heinrich 0
.......
TABLE: Therapy
T_ID P_ID ROOM STATION
---- ---- ---- -------
1 1 9 2
P_ID in table Therapy is the foreign key values to the primary key in table patient.
Now I want to write a Merge statement that looks if the last_name and first_name in table info_tmp is equal with the last_name and first_name in table patient. If yes then it must update the tables patient and therapy. If not then it must insert the rows in table info_tmp in the tables patient and therapy.
Is it possible to update or insert into more then one table?