下面是從
adf guide
中總結的一段呼叫
plsql
儲存過程和函式的方法,僅供參考。
1,呼叫沒有引數的儲存過程
可以使用
executecommand
() 函式,在
am 的實現類中可以這樣來使用:
getdbtransaction().executecommand("begin devguidepkg.proc_with_no_args; end;");
2 ,呼叫只有輸入引數的儲存過程
可以使用
getdbtransaction
提供的createpreparedstatement
來建立preparedstatement
物件,使用示例:
getdbtransaction().createpreparedstatement("begin "+stmt+";end;",0);
3 ,呼叫只有輸入引數的儲存函式
可以使用
getdbtransaction
提供的createcallablestatement
來建立callablestatement
物件,使用示例:
getdbtransaction().createcallablestatement("begin ? := "+stmt+";end;",0);
4 ,其他情況
呼叫既有輸入引數又有輸出引數的儲存過程或函式可以使用
callablestatement
,使用方法和
3 相同。
5,呼叫儲存過程
操作流程: 1)
建立preparedstatement
2)
設定輸入輸出引數 3)
執行查詢 4)
關閉語句鏈結
5
,注意點: 1)
資料庫連線占用資料庫資源,務必在finally 語句中關閉資料庫連線。 2)
對於在執行過程中發生的錯誤要throw 出來,否則會增加除錯時尋找異常(錯誤)的難度。 3)
執行查詢方法execute, executequery, executeupdate 的區別:
executeupdate
用於執行帶有insert/update/delete 操作的語句
executequery
用於執行帶有查詢操作的語句
execute
用於執行任意型別的sql 語句
在 PL SQL 中呼叫儲存過程 oracle
在 pl sql 中呼叫儲存過程 oracle 1 在sql的執行視窗中只能這樣呼叫 call out time 這樣執行就是把 call out time 當成乙個sql語句,而exec out time 不是乙個sql語句,是乙個執行體,執行體呼叫必須在命令視窗,把這句話當成乙個整體,也就是pl...
在PL SQL中呼叫儲存過程 oracle
在oracle10中寫好了儲存過程,如下 create orreplace procedure proc insert sname invarchar2 sage inint etime invarchar2 is begin insert into t test c id,c name,c age...
PL Sql 中建立 除錯 呼叫儲存過程
儲存過程 所用函式說明 功能 求和與差 原形 getsumandsub p1 in number p2 in number m out number b out number 引數 m p1 p2 b p1 p2 1.先建儲存過程 左邊的瀏覽視窗選擇 procedures 會列出所有的儲存過程,右擊...