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

Oracle數(shù)據(jù)庫在存儲過程中經常出現(xiàn)的若干問題

數(shù)據(jù)庫 Oracle
本文主要描述的是Oracle數(shù)據(jù)庫在存儲過程中出現(xiàn)的若干問題,如果你在相關的實際操作中遇到過這些的問題,卻不知道如何解決的話,以下的文章或許會幫助你。

以下的文章主要是對Oracle數(shù)據(jù)庫在存儲過程中出現(xiàn)的若干問題的深入討論,如果你想對Oracle數(shù)據(jù)庫在存儲過程中出現(xiàn)的若干問題有個詳細了解的話,以下就是詳細內容的描述,希望在你今后的學習中會有所幫助。

 

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

 

 

  1. select a.appname from appinfo a; 

正確

 

 

  1. select a.appname from appinfo as a; 

錯誤。也許,是怕和Oracle中的存儲過程中的關鍵字as沖突的問題吧

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

 

  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...語法時,必須先確保Oracle數(shù)據(jù)庫中有該條記錄,否則會報出"no data found"異常。

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

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

 

  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.在存儲過程中,關于出現(xiàn)null的問題

假設有一個表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   

外鍵

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

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

 

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

 

end if;這樣就一切ok了。

6.Hibernate調用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. });  

 

延伸閱讀:

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

 

Oracle數(shù)據(jù)庫與SQL Server選型時注意的三個差異

 

Oracle 10g ASM 的一點經驗

 

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

 

文章出自:http://www.programbbs.com/doc/4831.htm

【編輯推薦】

  1. Oracle數(shù)據(jù)庫如何保持優(yōu)其良性能
  2. 探討怎樣回收Oracle監(jiān)聽器日志文件
  3. 發(fā)揮Oracle數(shù)據(jù)庫數(shù)據(jù)管理功能的方法
  4. Oracle 11g五大獨特特能的描述
  5. 怎樣恢復Oracle重做日志丟失的竅門
責任編輯:佚名 來源: programbbs
相關推薦

2010-04-06 13:07:45

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

2010-05-05 11:06:32

Oracle存儲過程

2010-04-21 08:50:08

2010-05-21 12:23:32

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

2011-04-11 13:28:31

Oracle安裝

2010-06-04 19:31:25

遠程MySQL權限

2011-03-04 17:38:52

2010-04-22 12:37:42

Oracle移植

2011-04-11 13:25:59

Sybase安裝

2021-08-05 15:36:34

NFV網(wǎng)絡設備

2010-04-15 15:42:11

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

2017-08-08 10:13:21

開源代碼開發(fā)

2010-06-10 13:34:17

MySQL5

2011-07-07 13:59:54

存儲過程遠程數(shù)據(jù)庫Oracle數(shù)據(jù)庫

2010-03-31 17:17:32

2010-07-14 10:51:45

SQL Server連

2010-04-23 10:30:17

Oracle移植

2010-04-07 16:41:50

Oracle SQL優(yōu)

2010-08-19 16:34:02

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

2021-12-29 06:28:23

探索式測試軟件測試開發(fā)
點贊
收藏

51CTO技術棧公眾號