志翔科技有限公司後勤網
Would you like to react to this message? Create an account in a few clicks or log in to continue.
志翔科技有限公司後勤網

後勤等待處理訊息站,請各位成員努力消除待工區
 
首頁首頁  Latest imagesLatest images  會員註冊會員註冊  登入登入  

 

 User 自訂Function呼叫stored procedure方式

向下 
發表人內容
flying
Admin
flying


文章數 : 207
注冊日期 : 2008-11-11

User 自訂Function呼叫stored procedure方式 Empty
發表主題: User 自訂Function呼叫stored procedure方式   User 自訂Function呼叫stored procedure方式 Empty周五 11月 21, 2008 11:29 am

說明如何在自訂 Powerbuilder 自訂 Function 中呼叫 stored procedure 執行

Function Myfunc()

mtranno=dw_focus.getitemstring(1,"tranno")
mproc=""
moperate=""

//經過測試,MS SQL與Sybase用法不同,但PB的說明檔似乎只針對 Sybase
//一個Function裡面呼叫多次執行,Declare 只需一次即可.
DECLARE stock_proc PROCEDURE FOR sp_post
(:mtrantype ,:mtranno, :mproc,:moperate); //for MS SQL or ORACLE use only
//@trantype =:mtrantype ,@tranno =:mtranno, @task=:mproc,@mvtype=:moperate; //for sybase use only

//第一次執行PR
mtrantype="PR"
EXECUTE stock_proc ;
if sqlca.sqlcode= -1 then
 messagebox("Notice","SP_POST failed before Deleting PR.~n~n"+sqlca.sqlerrtext)
 return 0
end if
commit using sqlca;

//第二次執行PX
mtrantype="PX"
EXECUTE stock_proc ;
if sqlca.sqlcode= -1 then
 messagebox("Notice","SP_POST failed before Deleting PX.~n~n"+sqlca.sqlerrtext)
 return 0
end if
commit using sqlca;

重複執行只需先改變變數,再次呼叫執行即可
這個stored procedure並未接收回傳資料,沒有用到Open,Fetch,所以就不必加 Close.
回頂端 向下
http://idon.666forum.net
 
User 自訂Function呼叫stored procedure方式
回頂端 
1頁(共1頁)

這個論壇的權限:無法 在這個版面回復文章
志翔科技有限公司後勤網 :: 系統主題 :: 系統架構-
前往: