兩個儲存過程例子
create or replace procedure p_employeeinsert(
arg_employeeid tb_employeeinfo.employeeid%type,
arg_name tb_employeeinfo.name%type,
arg_*** tb_employeeinfo.***%type,
arg_age tb_employeeinfo.age%type,
arg_education tb_employeeinfo.education%type,
arg_address tb_employeeinfo.address%type)
isbegin
insert into tb_employeeinfo(
employeeid,
name,
***,
age,
education,
address)
values(arg_employeeid,
arg_name,
arg_***,
arg_age,
arg_education,
arg_address);
end;
/create or replace procedure p_getname(
arg_employeeid in tb_employeeinfo.employeeid%type,
arg_name out tb_employeeinfo.name%type)
iscursor c_getname is
select name from tb_employeeinfo where employeeid=arg_employeeid;
begin
open c_getname;
fetch c_getname into arg_name;
close c_getname;
end;
/執行exec p_employeeinsert('2008','網','nan',76,'han','yu');
oracle錯誤時,先看語法錯誤,再根據show errors檢視錯誤提示,根據錯誤提示改正,還有注意關鍵字的大小寫,空格等,有時就會出錯。
帶異常的儲存過程
create or replace procedure add_emp
(eno number,name varchar2,sal number,job varchar2 default 'clerk',dno number)
ise_integrity exception;
pragma exception_init(e_integrity,-2291);
begin
insert into emp(empno,ename,sal,job,deptno)
values(eno,name,sal,job,dno);
exception
when dup_val_on_index then
when e_integrity then
end;
/顯示儲存過程
select text from user_source where name='add_emp';
Oracle儲存過程呼叫儲存過程
oracle儲存過程呼叫有返回結果集的儲存過程一般用光標的方式,宣告乙個游標,把結果集放到游標裡面,然後迴圈游標 declare newcs sys refcursor cs1 number cs2 number cstype table rowtype table列的個數和newcs返回的個數一樣...
ORACLE儲存過程
自定義函式開始 create or replace function fn wftemplateidget templatecategoryid number,organid number,templatemode number return number istemplateid number i...
Oracle 儲存過程
create or replace procedure p 有就替換,沒有就建立 iscursor c is select from emp for update begin for v emp in c loop if v emp.deptno 10 then update emp2 set sa...