一. 存储过程
1. 语法
create or replace procedure procedureName(seqName varchar2) is /*声明变量*/ n number(10); cursor cur is select * from tableName; /*用来放置游标中的一行*/ cRow cur%rowtype; begin /*变量赋值*/ n := 5; /*循环方式一*/ for i in 1..n loop /*做点什么*/ end loop; /*循环方式二*/ loop exit when n = 0; n := n - 1; end loop; /*循环方式三*/ while i < n loop exit; end loop; /*游标用法一:隐式打开和关闭*/ for c in cur loop /*做点什么*/ end loop; /*游标用法一:显式打开和关闭*/ open cur; loop fetch cur into cRow; exit when cur%notfound; end loop; close cur; /*修改游标的所在行*/ update tableName set columnName=columnValue where current of cur; /*判断*/ if (n = 0) then /*动态执行sql语句*/ execute immediate 'select '||seqName||'.nextval from dual' into n; else /*控制台输出*/ dbms_output.put_line(n); end if; commit; end procedureName;