例句:
CREATE OR REPLACE PROCEDURE ADD_BOUNS (emp_no INTEGER, bonus REAL) IS
old_salary REAL;
new_salary REAL;
overdrawn EXCEPTION;
BEGIN
SELECT sal INTO old_salary FROM EMP
WHERE empno = emp_no;
new_salary := old_salary + bonus;
IF new_salary < 0 THEN
RAISE overdrawn;
ELSE
UPDATE EMP SET sal = new_salary
WHERE empno = emp_no;
COMMIT;
END IF;
EXCEPTION
WHEN overdrawn THEN
NULL;
END ADD_BOUNS;如果是循环结构,若用到while:
WHILE <condition> LOOP
<sequence_of_statements>;
END LOOP;或者 用到for:
FOR <counter> IN [REVERSE] <low>..<high> LOOP
<sequence_of_statements>;
END LOOP;FOR i IN 1..3 LOOP -- assign the values 1,2,3 to i
sequence_of_statements -- executes three times
END LOOP;FOR i IN REVERSE 1..3 LOOP -- assign the values 3,2,1 to i
sequence_of_statements -- executes three times
END LOOP;FOR i IN REVERSE 1..3 LOOP -- assign the values 3,2,1 to i
dbms_output.put_line(i);
i := i + 1; -- illegal
END LOOP;
CREATE OR REPLACE PROCEDURE ADD_BOUNS (emp_no INTEGER, bonus REAL) IS
old_salary REAL;
new_salary REAL;
overdrawn EXCEPTION;
BEGIN
SELECT sal INTO old_salary FROM EMP
WHERE empno = emp_no;
new_salary := old_salary + bonus;
IF new_salary < 0 THEN
RAISE overdrawn;
ELSE
UPDATE EMP SET sal = new_salary
WHERE empno = emp_no;
COMMIT;
END IF;
EXCEPTION
WHEN overdrawn THEN
NULL;
END ADD_BOUNS;如果是循环结构,若用到while:
WHILE <condition> LOOP
<sequence_of_statements>;
END LOOP;或者 用到for:
FOR <counter> IN [REVERSE] <low>..<high> LOOP
<sequence_of_statements>;
END LOOP;FOR i IN 1..3 LOOP -- assign the values 1,2,3 to i
sequence_of_statements -- executes three times
END LOOP;FOR i IN REVERSE 1..3 LOOP -- assign the values 3,2,1 to i
sequence_of_statements -- executes three times
END LOOP;FOR i IN REVERSE 1..3 LOOP -- assign the values 3,2,1 to i
dbms_output.put_line(i);
i := i + 1; -- illegal
END LOOP;
解决方案 »
- 但是用./runcluvfy.sh 是都通过的...
- 如何将xml导入到oracle中
- tiptop ERP如何连接到sqlserver数据库?
- oracle 10g最近是不是要疯?
- 关于oracle中的完整性约束
- 触发器里面能写逻辑判断吗?
- 我在SQL*plus里能select 到一个表的几条记录,是通过存储过程插入的,但在表数据编辑器窗口里什么都没有,为什么?
- 這個sql語句哪裡錯了阿
- 谁有SQL Navigator 3的authorization key?
- 请问如何取出一个varchar2型字段最后5位的值,字段实际为字符串和数字的组合,我想取出后面的数字
- ASP中的Oracle的SQL语句问题
- 磁盘空间的奇怪问题!
as
beginend aa;
as
cursor g_cursor is select * from table1 where id=vid for updatel;
num number:=0;
begin
for aa in g_cursor loop
update table1 set name=vname where current of g_cursor;
if mod(num,200)=0 then
commit;
end if
num:=num+1;
end loop;
end aa;