DEFINETABLE: SCORE: Keys: thebaseinformationofstudentsDEFINECOLUMNS: STUNO: thestudentsIDintheUniversitySTUNAME: studentsnameCOURSENAME: coursenameCOURSESCORE: t
Define table: SCORE: using for save the students score informations STUDENTS: the base information of students define columns: STUNO: the students 'Id in theUniversity STUNAME: students 'name COURSENAME: course name COURSESCORE: t
Define table:
SCORE: using for save the students 'score informations
STUDENTS: the base information of students
Define columns:
STUNO: the students 'Id in the University
STUNAME: students 'name
COURSENAME: course name
COURSESCORE: the study-results of the reference course
CLASSNAME: where the students study in
STUGRADE: the students grade
TERMNAME: the term which the reference course studied
Now beagin to write down the statement here blow this line!
MERGE INTO SCORE S
USING
(
Select a. *, B .*,? Myscore from score a, STUDENT B
WHERE
A. CLASSNO =? And a. GRADE =?
And a. TERMNAME =? And a. COURSENAME =?
A. STUNO = B. STUNO (+)
) X
ON
(S. STUNO = X. STUNO)
WHEN
MATHED
THEN
Update set coursescore = X. MYSCORE
WHEN
NOT MATHED
THEN
INSERT
(
STUNO, STUNAME, COURSENAME, COURSESCORE,
CLASSNAME, STUGRADE, TERMNAME
)
VALUES
(
X. STUNO, X. STUNAME, X. COURSENAME, X. MYSCORE,
X. CLASSNAME, X. STUGRADE, X. TERMNAME
);
NotesMERGEStatement at the end of ";" (semicolon), which only takesMERGEFor a completeSQLStatement.
[1] [2]