Oracle存储过程实际应用代码详细描述

以下的文章主要介绍的是Oracle存储过程的实际操作用法,本文主要是以相关实际应用代码的方式来引出Oracle存储过程的实际操作,下面就是文章的具体内容介绍,望你浏览之后会对其有更深的了解。

成都创新互联是一家集网站建设,吉安企业网站建设,吉安品牌网站建设,网站定制,吉安网站建设报价,网络营销,网络优化,吉安网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

 
 
 
  1. create table stuInfo  
  2. (  
  3. stuID int primary key,  
  4. stuName varchar2(20)  
  5. )  
  6. create or replace procedure proc1  
  7. is  
  8. begin  
  9. insert into stuInfo values(1,'liheng');  
  10. end;  
  11. create or replace procedure proc2  
  12. (  
  13. v_ID int,  
  14. v_Name varchar2  
  15. )  
  16. is  
  17. begin  
  18. insert into stuInfo values(v_ID,v_Name);  
  19. commit;  

记得要提交

 
 
 
  1. end;  
  2. create or replace procedure proc3  
  3. (  
  4. v_ID int,  
  5. v_Name out varchar2  
  6. )  
  7. is  
  8. varName stuInfo.Stuname%type;  
  9. begin  
  10. select stuName into varName from stuInfo where stuID=v_ID;  
  11. v_Name:=varName;  
  12. end;  

 

返回全部记录

 
 
 
  1. create or replace package PKG_STUINFO is  
  2. type stuInfoCursorType is ref cursor;  
  3. procedure getStuInfo (stuInfoCursor out stuInfoCursorType);  
  4. end;  
  5. create or replace package body PKG_STUINFO is  
  6. procedure getStuInfo (stuInfoCursor out stuInfoCursorType)  
  7. is  
  8. var_cursor stuInfoCursorType;  
  9. begin  
  10. open var_cursor for select * from stuInfo;  
  11. stuInfoCursor:=var_cursor;  
  12. end;  
  13. end;  

 

Oracle存储过程的中我们要根据编号返回记录

 
 
 
  1. create or replace package PKG_STUINFO is  
  2. type stuInfoCursorType is ref cursor;  
  3. procedure getStuInfo (v_ID int,stuInfoCursor out stuInfoCursorType);  
  4. end;  
  5. create or replace package body PKG_STUINFO is  
  6. procedure getStuInfo (v_ID int,stuInfoCursor out stuInfoCursorType)  
  7. is  
  8. var_cursor stuInfoCursorType;  
  9. begin  
  10. if v_ID=0 then  
  11. open var_cursor for select * from stuInfo;  
  12. else  
  13. open var_cursor for select * from stuInfo where stuID=v_ID;  
  14. end if;  
  15. stuInfoCursor:=var_cursor;  
  16. end;  
  17. end;  

 

根据姓名返回记录

 
 
 
  1. create or replace package PKG_STUINFO is  
  2. type stuInfoCursorType is ref cursor;  
  3. procedure getStuInfo (v_Name varchar2,stuInfoCursor out stuInfoCursorType);  
  4. end;  
  5. create or replace package body PKG_STUINFO is  
  6. procedure getStuInfo (v_Name varchar2,stuInfoCursor out stuInfoCursorType)  
  7. is  
  8. var_cursor stuInfoCursorType;  
  9. begin  
  10. if v_Name =' ' then  
  11. open var_cursor for select * from stuInfo;  
  12. else  
  13. open var_cursor for select * from stuInfo where stuName like '%'||v_Name||'%';  
  14. end if;  
  15. stuInfoCursor:=var_cursor;  
  16. end;  
  17. end;   

上述的相关内容就是对Oracle存储过程的用法的描述,希望会给你带来一些帮助在此方面。

当前名称:Oracle存储过程实际应用代码详细描述
网站链接:http://www.shufengxianlan.com/qtweb/news46/149696.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联