我需要写这样的存储过程,逻辑简单描述是这样的:
1:从学生表里查询已经参加过考试的学生的id
2:用这些id 再从成绩表,课程表里取得数据填充到另外得表里。
我想要用到cursor,循环等等,但我对oracle 半知半解,请大家帮我写这个SP 的结构?谢谢!
1:从学生表里查询已经参加过考试的学生的id
2:用这些id 再从成绩表,课程表里取得数据填充到另外得表里。
我想要用到cursor,循环等等,但我对oracle 半知半解,请大家帮我写这个SP 的结构?谢谢!
解决方案 »
- 一个oracle运维人员需要学会什么东西?谢谢
- linux5上安装oracle10g
- 怎么在oracle的表级触发器调用web services
- oracle 10的数据库迁移。。。急
- 求一Sql语句,如果有重复的根据某字段条件来取数据
- 存储过程返回记录集的问题
- 如何不在本机安装ORALCE,就可以在远程访问Oracle
- 有无等价SQL SERVER的语句:select convert(varchar(20),getdate(),120),convert(varchar(20),dateadd(mi,30,getdate()),120)
- 非常菜的初级问题,立马结帖!!!
- oracle自表关联求优化
- 服务器可以连结,客户Normal可以连结,system及sys用户不能连结????
- 局域网内,知道某服务器的ip,windows下如何知道该服务器上的oracle 数据库名 和所在端口?谢谢各位朋友
insert into course_score
(student_id, student_name, course_name, score_value)
select s.student_id, s.student_name, b.course_name, a.score_value
from student s, score a, course b
where a.course_id = b.course_id
and s.student_id = a.student_id
and s.status = '已参加'
否则,就只有循环插入了。
cursor aa is
select id,..
from..
;for v in aa loopinsert into bb
values v.id...; commit;
end loop;
是一个值,就会造成主键冲突
(student_id, student_name, course_name, score_value)
select s.student_id, s.student_name, b.course_name, a.score_value
from student s, score a, course b
where a.course_id = b.course_id
and s.student_id = a.student_id
and s.status = '已参加'谢谢二楼的回答,但是我编译不过啊?在select 的地方报错。
(student_id, student_name, course_name, score_value)
select s.student_id, s.student_name,'Chinese' course_name, a.score_value
from student s, score a, course b
where a.course_id = b.course_id
and s.student_id = a.student_id
and s.status = '已参加'