射精一区欧美专区|国产精品66xx|亚洲视频一区导航|日韩欧美人妻精品中文|超碰婷婷xxnx|日韩无码综合激情|特级黄片一区二区|四虎日韩成人A√|久久精品内谢片|亚洲成a人无码电影

您現(xiàn)在的位置:首頁 > IT認證 > oracle認證 >

Oracle備份恢復(fù):oracle存儲過程注意事項


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

    [html] 

    select a.appname from appinfo a;-- 正確  

    select a.appname from appinfo as a;-- 錯誤  

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

    [html] 

    select af.keynode into kn from APPFOUNDATION af where af.appid=aid and af.foundationid=fid;-- 有into,正確編譯  

    select af.keynode from APPFOUNDATION af where af.appid=aid and af.foundationid=fid;-- 沒有into,編譯報錯,提示:Compilation   

    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.在存儲過程中,別名不能和字段名稱相同,否則雖然編譯可以通過,但在運行階段會報錯

    [html] 

    select keynode into kn from APPFOUNDATION where appid=aid and foundationid=fid;-- 正確運行  

    select af.keynode into kn from APPFOUNDATION af where af.appid=appid and af.foundationid=foundationid;-- 運行階段報錯,提示  

    ORA-01422:exact fetch returns more than requested number of rows  

     

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

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

    [html] 

    create table A(  

    id varchar2(50) primary key not null,  

    vcount number(8) not null,  

    bid varchar2(50) not null -- 外鍵   

    );  

 

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

    [html] 

    select sum(vcount) into fcount from A where bid='xxxxxx';  

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

    [html] 

    if fcount is null then  

        fcount:=0;  

    end if;  

    這樣就一切ok了。

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

    [html] 

    this.pnumberManager.getHibernateTemplate().execute(  

                    new HibernateCallback() ...{  

                        public Object doInHibernate(Session session)  

                                throws HibernateException, SQLException ...{  

                            CallableStatement cs = session  

                                    .connection()  

                                    .prepareCall("{call modifyapppnumber_remain(?)}");  

                            cs.setString(1, foundationid);  

                            cs.execute();  

                            return null;  

                        }  

                    });

相關(guān)文章

無相關(guān)信息
更新時間2022-03-13 11:18:59【至頂部↑】
聯(lián)系我們 | 郵件: | 客服熱線電話:4008816886(QQ同號) | 

付款方式留言簿投訴中心網(wǎng)站糾錯二維碼手機版

客服電話: