自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle通過存儲過程如何正確返回數(shù)據(jù)集?

數(shù)據(jù)庫 Oracle
以下的文章Oracle通過存儲過程中返回數(shù)據(jù)集的實(shí)際應(yīng)用,我前兩天在相關(guān)網(wǎng)站看見的資料,覺得挺好,就拿出來供大家分享。

文章主要教會你如何正確的使用Oracle存儲過程使其返回相關(guān)的數(shù)據(jù)集的實(shí)際操作步驟,我們大家都知道在Oracle中存儲過程的返回相關(guān)的數(shù)據(jù)集主要作用是通過相關(guān)ref cursor類型數(shù)據(jù)的實(shí)際應(yīng)用參數(shù)返回的,而返回數(shù)據(jù)的參數(shù)應(yīng)該是out或in out類型的。

由于在定義Oracle存儲過程時無法直接指定參數(shù)的數(shù)據(jù)類型為:ref cursor,而是首先通過以下方法將ref cursor進(jìn)行了重定義:

 

  1. create or replace package FuxjPackage is  
  2. type FuxjResultSet is ref cursor;  

 

還可以定義其他內(nèi)容

 

  1. end FuxjPackage; 

再定義Oracle存儲過程:

 

  1. create or replace procedure UpdatefuxjExample 
    (sDM in char,sMC in char, pRecCur in out FuxjPackage.FuxjResultSet)  
  2. as  
  3. begin  
  4. update fuxjExample set mc=sMC where dm=sDM;  
  5. if SQL%ROWCOUNT=0 then  
  6. rollback;  
  7. open pRecCur for  
  8. select '0' res from dual;  
  9. else  
  10. commit;  
  11. open pRecCur for  
  12. select '1' res from dual;  
  13. end if;  
  14. end;  

 

 

  1. create or replace procedure InsertfuxjExample 
    (sDM in char,sMC in char, pRecCur in out FuxjPackage.FuxjResultSet)  
  2. as  
  3. begin  
  4. insert into FuxjExample (dm,mc) values (sDM,sMC);  
  5. commit;  
  6. open pRecCur for  
  7. select * from FuxjExample;  
  8. end;  

 

二、在Delphi中調(diào)用返回數(shù)據(jù)集的Oracle存儲過程

可以通過TstoredProc或TQuery控件來調(diào)用執(zhí)行返回數(shù)據(jù)集的存儲,數(shù)據(jù)集通過TstoredProc或TQuery控件的參數(shù)返回,注意參數(shù)的DataType類型為ftCursor,而參數(shù)的ParamType類型為ptInputOutput。

使用TstoredProc執(zhí)行UpdatefuxjExample的相關(guān)設(shè)置為:

 

  1. object StoredProc1: TStoredProc  
  2. DatabaseName = 'UseProc' 
  3. StoredProcName = 'UPDATEFUXJEXAMPLE' 
  4. ParamData = < 
  5. item 
  6. DataType = ftString 
  7. Name = 'sDM' 
  8. ParamType = ptInput 
  9. end  
  10. item  
  11. DataType = ftString 
  12. Name = 'sMC' 
  13. ParamType = ptInput 
  14. end  
  15. item  
  16. DataType = ftCursor 
  17. Name = 'pRecCur' 
  18. ParamType = ptInputOutput 
  19. Value = Null 
  20. end> 
  21. end   

以上的相關(guān)內(nèi)容就是對Oracle存儲過程中返回數(shù)據(jù)集的介紹,望你能有所收獲。

【編輯推薦】

  1. Oracle建立DBLINK的操作經(jīng)驗總結(jié)
  2. Oracle查詢記錄數(shù)在什么環(huán)境下會出現(xiàn)問題?
  3. Oracle字符集的查看與修改全集
  4. Oracle 分頁和排序功能在數(shù)據(jù)庫中如何實(shí)現(xiàn)?
  5. Oracle移植到MySQL會碰到那些問題?

 

責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-04-30 14:22:43

Oracle通過

2011-04-12 11:12:20

Oracle存儲過程

2010-05-10 10:46:07

Oracle存儲過程

2011-08-18 17:32:40

Oracle存儲過程利用游標(biāo)返回結(jié)果集

2010-04-26 10:09:22

Oracle存儲過程

2010-04-29 17:31:56

Oracle存儲過程

2009-09-17 10:27:55

linq存儲過程

2011-05-18 10:07:13

oracle存儲

2011-08-25 09:31:43

JDBC調(diào)用Oracl

2011-04-15 10:56:22

2010-10-26 14:40:31

oracle存儲過程

2010-03-30 13:30:49

Oracle存儲

2010-11-29 09:34:39

Sybase數(shù)據(jù)庫存儲

2010-05-05 17:19:32

Oracle存儲過程

2010-03-30 13:19:57

Oracle存儲

2010-01-08 13:23:38

ibmdwInfoSphere

2011-08-29 15:52:19

SQL ServerMybatis存儲過程

2009-07-08 17:42:33

JDBC存儲過程

2011-05-17 15:30:27

Oracle數(shù)據(jù)庫ADO

2010-05-06 15:29:53

Oracle數(shù)據(jù)復(fù)制
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號