pl/sql关于赋值的小小注意

来源:互联网 发布:tomcat运行php 编辑:程序博客网 时间:2024/06/05 12:05

在sqlplus执行下列的pl/sql语句,

declare

  v_comm emp.comm%type;
begin
  select comm into v_comm from emp where empno = &&no;
  if v_comm <> 0 then
    update emp set comm = comm + 100 where empno = &no;
  else
    update emp set comm = 200 where empno = &no;
  end if;
end;
/

由于&&no将no做了类似宏定义,所以接着执行同样的pl/sql或者采用&no传值是,会自动使用原来的no的值。为了赋新值,需要执行如下:

SQL> undefine no


0 0
原创粉丝点击