以下的文章是通过介绍Oracle存储过程的相关实际应用代码,来剖析Oracle存储过程的实际应用,以下就是相关内容的详细介绍。以下是文章的具体介绍,望你浏览完以下的内容会有所收获。

成都创新互联公司专业为企业提供宁强网站建设、宁强做网站、宁强网站设计、宁强网站制作等企业网站建设、网页设计与制作、宁强企业网站模板建站服务,10年宁强做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Oracle存储过程的用法
- create table stuInfo
 - (
 - stuID int primary key,
 - stuName varchar2(20)
 - )
 - create or replace procedure proc1
 - is
 - begininsert into stuInfo values(1,'liheng');
 - end;
 - create or replace procedure proc2
 - (
 - v_ID int,
 - v_Name varchar2
 - )
 - is
 - begin
 - insert into stuInfo values(v_ID,v_Name);
 
在Oracle存储过程中commit;---------记得要提交
- end;
 - create or replace procedure proc3
 - (
 - v_ID int,
 - v_Name out varchar2
 - )
 - is
 - varName stuInfo.Stuname%type;
 - begin
 - select stuName into varName from stuInfo where stuID=v_ID;
 - v_Name:=varName;
 - end;
 
返回全部记录
- create or replace package PKG_STUINFO is
 - type stuInfoCursorType is ref cursor;
 - procedure getStuInfo (stuInfoCursor out stuInfoCursorType);
 - end;
 - create or replace package body PKG_STUINFO is
 - procedure getStuInfo (stuInfoCursor out stuInfoCursorType)
 - is
 - var_cursor stuInfoCursorType;
 - begin
 - open var_cursor for select * from stuInfo;
 - stuInfoCursor:=var_cursor;
 - end;
 - end;
 
根据编号返回记录
- create or replace package PKG_STUINFO is
 - type stuInfoCursorType is ref cursor;
 - procedure getStuInfo
 
(v_ID int,stuInfoCursor out stuInfoCursorType);- end;
 - create or replace package body PKG_STUINFO is
 - procedure getStuInfo
 
(v_ID int,stuInfoCursor out stuInfoCursorType)- is
 - var_cursor stuInfoCursorType;
 - begin
 - if v_ID=0 then
 - open var_cursor for select * from stuInfo;
 - else
 - open var_cursor for select * from stuInfo
 
where stuID=v_ID;- end if;
 - stuInfoCursor:=var_cursor;
 - end;
 - end;
 
根据姓名返回记录
- create or replace package PKG_STUINFO is
 - type stuInfoCursorType is ref cursor;
 - procedure getStuInfo
 
(v_Name varchar2,stuInfoCursor out stuInfoCursorType);- end;
 - create or replace package body PKG_STUINFO is
 - procedure getStuInfo
 
(v_Name varchar2,stuInfoCursor out stuInfoCursorType)- is
 - var_cursor stuInfoCursorType;
 - begin
 - if v_Name =' ' then
 - open var_cursor for select * from stuInfo;
 - else
 - open var_cursor for select * from stuInfo where stuName like '%'||v_Name||'%';
 - end if;
 - stuInfoCursor:=var_cursor;
 - end;
 - end;
 
上述的相关内容就是对Oracle存储过程的用法的描述,希望会给你带来一些帮助在此方面。
                网站标题:Oracle存储过程的代码的介绍
                
                本文路径:http://www.csdahua.cn/qtweb/news16/212716.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网