日期:2014-05-16 浏览次数:20417 次
declare cursor venList is select * from tbl_venue ; begin --for循环 for ven in venList loop dbms_output.put_line('部门名称:'||VEN.id); end loop; --COMMIT; end ;
create or replace trigger 触发器名称 after/before INSERT OR UPDATE OR DELETE on 表名 for each row declare mesg varchar2(100); begin case when inserting then begin mesg := '赋值'; 用 :new来取新属性值,如: :new.id EXception when others then dbms_output.put_line('部门名称:' ||:old.id); end; when updating then begin mesg := '赋值'; 用 :new来取新属性值,如: :new.id 用 :old来取旧属性值,如: :old.id EXception when others then dbms_output.put_line('部门名称:' ||:old.id); end; when deleting then begin mesg := '赋值'; 用 :old来取旧属性值,如: :old.id EXception when others then dbms_output.put_line('部门名称:' || :old.id); end; end case; end;
create or replace function getReportDate(param in varchar2 .. .) return varchar2 is --返回类型 accept_time varchar2(1000); v_acc_nbr date; CURSOR cur_1 is select sysdate from daul; --定义游标 begin open cur_1; --打开游标 loop fetch cur_1 into v_acc_nbr; --单个属性值 exit when cur_1%notfound; if accept_time is null then ----执行语句 else ----执行语句 end if; end loop; close cur_1; return(accept_time); --返回 end getReportDate;
create or replace function getReportDate(param in varchar2 .. .) return varchar2 is --返回类型 accept_time varchar2(1000); p1 date; p2 date; p3 date; CURSOR cur_1 is select sysdate,sysdate,sysdate from daul; --定义游标 begin open cur_1; --打开游标 loop fetch cur_1 into p1,p2,p3; --多个属性值 exit when cur_1%notfound; if accept_time is null then ----执行语句 else ----执行语句 end if; end loop; close cur_1; return(accept_time); --返回 end getReportDate;
create or replace procedure 存储过程名称 is--无参 --create or replace procedure 存储过程名称(queryPara varchar2.. .) is --有参 sql_set varchar2(1024); --定义变量 cursor crData is select * from 表名; begin for rowData in crData loop --捕捉异常 BEGIN dbms_output.put_line('打印:' || rowData.id); EXCEPTION WHEN OTHERS THEN dbms_output.put_line('打印:'); END; end loop; end 存储过程名称;