create or replace trigger update_xskc
before update on xs_kc
for each row
begin
declare
s integer(6);
begin
select count(*) into s from xs where xs.xh=:new.xh;
end;
if s<>0 then update xs_kc set xh=:new.xh where xh=:old.xh;
end if;
end update_xskc;
/意思就是说在向xs_kc(学生课程)表中更新数据时(更新xh即学号)如果要更新的数据(:new.xh)在xs(学生)表中有的话,就进行更新。用sqlplus执行时提示出错,上边说“此上下文中不允许表, 视图或序列引用 'S'”。
请高人解答如何修改代码
before update on xs_kc
for each row
begin
declare
s integer(6);
begin
select count(*) into s from xs where xs.xh=:new.xh;
end;
if s<>0 then update xs_kc set xh=:new.xh where xh=:old.xh;
end if;
end update_xskc;
/意思就是说在向xs_kc(学生课程)表中更新数据时(更新xh即学号)如果要更新的数据(:new.xh)在xs(学生)表中有的话,就进行更新。用sqlplus执行时提示出错,上边说“此上下文中不允许表, 视图或序列引用 'S'”。
请高人解答如何修改代码
解决方案 »
- 一个诡异的SQL语句问题
- oracle 多条查询记录 结果连接
- 我想在新增一条记录之后,取得一个由触发器生成的数据
- ORACLE数据大数据量插入问题请教
- 如何使sql语句在多个cpu上并行运行?
- 如何在说有表中查找某一字段的内容
- oracle 8服务启动不了?在线等待!!!
- 安装Oracle9i Application Server Enterprise Edition for Win2000的问题
- 菜鸟的问题
- asp ,连接orcal,乱码,求大神,页面当中utf-8,gb2312都设置过了,还是不行,直接在页面打印汉字都没有问题
- oracle10g修改了监听端口,sys用户在PL/SQL中能登陆,sqlplus中无法登陆?
- "Global Cache Blocks Lost" 位于9
create or replace trigger update_xskc
before update on xs_kc
for each row
--begin 这个是多余的
declare
s integer(6);
begin
select count(*) into s from xs where xs.xh=:new.xh;
--end; 这个也是多余的
if s <>0 then update xs_kc set xh=:new.xh where xh=:old.xh;
end if;
end update_xskc;
/
原因,字块中的变量 只能在字块中使用,作用范围不能超出字块的范围。