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

Oracle存儲過程中易出現(xiàn)的若干問題的探討

數(shù)據(jù)庫 Oracle
以下的文章主要是淺談Oracle存儲過程中易出現(xiàn)的若干問題,我在一個信譽(yù)度很好的網(wǎng)站找到一個關(guān)于其的資料,拿出來供大家分享

以下的文章主要是對Oracle存儲過程中易出現(xiàn)的若干問題的探討,Oracle存儲過程在實際中的應(yīng)用比例還是占為多數(shù)的,如果你對這一技術(shù),心存好奇的話,以下的文章將會揭開它的神秘面紗。希望你在瀏覽完之后會有所收獲。

 

1.在Oracle中,數(shù)據(jù)表別名不能加as,如:

 

 

  1. select a.appname from appinfo a; 

正確 

  1. select a.appname from appinfo as a; 

錯誤

也許,是怕和Oracle存儲過程中的關(guān)鍵字as沖突的問題吧

2.在存儲過程中,select某一字段時,后面必須緊跟into,如果select整個記錄,利用游標(biāo)的話就另當(dāng)別論了。 

  1. select af.keynode into kn from APPFOUNDATION af where af.appid=aid and af.foundationid=fid

有into,正確編譯 

  1. select af.keynode from APPFOUNDATION af where af.appid=aid and af.foundationid=fid

沒有into,編譯報錯,提示:Compilation

  1. Error: PLS-00428: an INTO clause is expected in this Select statement  

3.在利用select...into...語法時,必須先確保數(shù)據(jù)庫中有該條記錄,否則會報出"no data found"異常。

可以在該語法之前,先利用select count(*) from 查看數(shù)據(jù)庫中是否存在該記錄,如果存在,再利用select...into...

4.在Oracle存儲過程中,別名不能和字段名稱相同,否則雖然編譯可以通過,但在運行階段會報錯 

  1. select keynode into kn from APPFOUNDATION where appid=aid and foundationid=fid

正確運行

  1. select af.keynode into kn from APPFOUNDATION af where af.appid=appid and af.foundationid=foundationid; 

 運行階段報錯,提示

  1. orA-01422:exact fetch returns more than requested number of rows  

5.在存儲過程中,關(guān)于出現(xiàn)null的問題

假設(shè)有一個表A,定義如下:

  1. create table A(   
  2. id varchar2(50) primary key not null,   
  3. vcount number(8) not null,   
  4. bid varchar2(50) not null  

外鍵

);如果在Oracle存儲過程中,使用如下語句:

select sum(vcount) into fcount from A where bid='xxxxxx';如果A表中不存在bid="xxxxxx"的記錄,則fcount=null(即使fcount定義時設(shè)置了默認(rèn)值,如:fcount number(8):=0依然無效,fcount還是會變成null),這樣以后使用fcount時就可能有問題,所以在這里最好先判斷一下:

  1. if fcount is null then   
  2. fcount:=0;   

end if;這樣就一切ok了。

6.Hibernate調(diào)用Oracle存儲過程

  1. this.pnumberManager.getHibernateTemplate().execute(   
  2. new HibernateCallback() ...{   
  3. public Object doInHibernate(Session session)   
  4. throws HibernateException, SQLException ...{   
  5. CallableStatement cs = session   
  6. .connection()   
  7. .prepareCall("{call modifyapppnumber_remain(?)}");   
  8. cs.setString(1, foundationid);   
  9. cs.execute();   
  10. return null;   
  11. }   
  12. });   

延伸閱讀:

詳細(xì)講解 DB2 9存儲過程的規(guī)劃和實施技

 

Oracle與SQL Server選型時注意的三個差異

 

Oracle 10g ASM 的一點經(jīng)驗

 

Oracle 9i和10g在create index和rebuild index的統(tǒng)計信息的區(qū)別

 

【編輯推薦】

  1. Oracle數(shù)據(jù)庫的統(tǒng)計數(shù)據(jù)與其生成的具體方式
  2. Oracle加速計劃與推出的新門戶網(wǎng)站簡介
  3. Oracle數(shù)據(jù)庫提升效率,用3PAR
  4. Oracle企業(yè)的績效管理統(tǒng)升級版簡介
  5. Oracle企業(yè)管理器11g獲合作伙伴青睞的原因
責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-04-20 10:01:16

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

2021-08-05 15:36:34

NFV網(wǎng)絡(luò)設(shè)備

2009-03-04 09:08:00

軟交換組網(wǎng)

2020-09-22 20:00:30

微服務(wù)架構(gòu)設(shè)計

2011-04-11 17:28:50

oracle存儲select語句

2021-12-29 06:28:23

探索式測試軟件測試開發(fā)

2010-04-07 09:21:03

Oracle RAC

2010-04-15 16:54:31

Oracle存儲過程

2024-11-21 10:05:14

2010-04-16 09:03:28

Oracle 存儲過程

2009-08-01 15:51:15

廣播電視網(wǎng)絡(luò)網(wǎng)絡(luò)規(guī)劃

2010-04-21 17:09:28

Oracle啟動模式

2010-05-05 14:55:15

Oracle存儲過程

2010-05-07 18:44:28

Oracle存儲過程

2009-09-07 22:08:24

虛擬機(jī)安裝Linux系

2009-12-02 10:22:26

阿爾法路由器固件

2010-04-13 12:32:38

Oracle字符集

2010-04-12 11:37:57

Oracle RAC

2010-04-16 10:24:17

Oracle存儲過程

2012-12-18 10:09:26

虛擬化應(yīng)用錯誤
點贊
收藏

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