您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle中的Merge函数(批量更新/删除)

2025/4/15 20:27:24发布42次查看
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
);
注意到 merge 语句在最后的“;”(分号),这仅仅带到 merge 为一条完整的 sql 语句。
[1] [2]
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product