RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Oracle存储过程的代码的介绍

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

成都创新互联公司专业为企业提供宁强网站建设、宁强做网站、宁强网站设计、宁强网站制作等企业网站建设、网页设计与制作、宁强企业网站模板建站服务,10年宁强做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

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. begininsert into stuInfo values(1,'liheng');
  9. end;
  10. create or replace procedure proc2
  11. (
  12. v_ID int,
  13. v_Name varchar2
  14. )
  15. is
  16. begin
  17. insert into stuInfo values(v_ID,v_Name);

在Oracle存储过程中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;

根据编号返回记录

 
 
 
  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.jxjierui.cn/article/dpejdpg.html