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

發(fā)展壯大離不開廣大客戶長期以來的信賴與支持,我們將始終秉承“誠信為本、服務(wù)至上”的服務(wù)理念,堅持“二合一”的優(yōu)良服務(wù)模式,真誠服務(wù)每家企業(yè),認(rèn)真做好每個細(xì)節(jié),不斷完善自我,成就企業(yè),實現(xiàn)共贏。行業(yè)涉及廣告推廣等,在成都網(wǎng)站建設(shè)、成都全網(wǎng)營銷、WAP手機(jī)網(wǎng)站、VI設(shè)計、軟件開發(fā)等項目上具有豐富的設(shè)計經(jīng)驗。
由于在定義Oracle存儲過程時無法直接指定參數(shù)的數(shù)據(jù)類型為:ref cursor,而是首先通過以下方法將ref cursor進(jìn)行了重定義:
- create or replace package FuxjPackage is
- type FuxjResultSet is ref cursor;
還可以定義其他內(nèi)容
- end FuxjPackage;
再定義Oracle存儲過程:
- create or replace procedure UpdatefuxjExample
(sDM in char,sMC in char, pRecCur in out FuxjPackage.FuxjResultSet)- as
- begin
- update fuxjExample set mc=sMC where dm=sDM;
- if SQL%ROWCOUNT=0 then
- rollback;
- open pRecCur for
- select '0' res from dual;
- else
- commit;
- open pRecCur for
- select '1' res from dual;
- end if;
- end;
和
- create or replace procedure InsertfuxjExample
(sDM in char,sMC in char, pRecCur in out FuxjPackage.FuxjResultSet)- as
- begin
- insert into FuxjExample (dm,mc) values (sDM,sMC);
- commit;
- open pRecCur for
- select * from FuxjExample;
- 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è)置為:
- object StoredProc1: TStoredProc
- DatabaseName = 'UseProc'
- StoredProcName = 'UPDATEFUXJEXAMPLE'
- ParamData = <
- item
- DataType = ftString
- Name = 'sDM'
- ParamType = ptInput
- end
- item
- DataType = ftString
- Name = 'sMC'
- ParamType = ptInput
- end
- item
- DataType = ftCursor
- Name = 'pRecCur'
- ParamType = ptInputOutput
- Value = Null
- end>
- end
以上的相關(guān)內(nèi)容就是對Oracle存儲過程中返回數(shù)據(jù)集的介紹,望你能有所收獲。
【編輯推薦】
- Oracle建立DBLINK的操作經(jīng)驗總結(jié)
- Oracle查詢記錄數(shù)在什么環(huán)境下會出現(xiàn)問題?
- Oracle字符集的查看與修改全集
- Oracle 分頁和排序功能在數(shù)據(jù)庫中如何實現(xiàn)?
- Oracle移植到MySQL會碰到那些問題?
本文題目:Oracle通過存儲過程如何正確返回數(shù)據(jù)集?
鏈接分享:http://m.fisionsoft.com.cn/article/cogeigh.html


咨詢
建站咨詢
