MasteringVFP/4/9
出自VFP Wiki
MasteringVFP/4/9
的原始碼
跳轉到:
導航
,
搜尋
根據以下的原因,您並無權限去做編輯這個頁面:
你所請求執行的操作被禁止。
你可以檢視並複製本頁面的原始碼。
個人是覺得 Trigger 很好用, 但是在不同的資料庫會有不同的語法,資料庫轉移上也會有問題, 而且也不是所有的資料庫都有 Trigger 功能, 例如 MySQL 就沒有(最新版有沒有不清楚, 有興趣至 MySQL 網站)。不少書藉不建議使用 Trigger, 不過如果只是小程式, 倒是可以寫寫看。 如果單純以 VFP 來說, Trigger 必須加進 DBC 內才有這功能。 一樣來舉個例子: <pre> CREATE DATABASE 測試 CREATE TABLE 庫存 (No C(10),Qty I) CREATE TABLE 進貨 (No C(10),Qty I) CREATE TABLE 出貨 (No C(10),Qty I) </pre> 上述是建立一個 [測試.dbc]、[庫存.DBF]、[進貨.DBF]、[出貨.DBF], 接下來在 [測試.dbc] 內的 Store Procedure 輸入以下的 Code <pre> * -------------------------------------------------- * 以下程式碼不考慮錯誤處理問題 * -------------------------------------------------- * 進貨時的 Insert Trigger * -------------------------------------------------- FUNCTION 進貨_insert() SELECT 庫存 LOCATE FOR No=進貨.No IF !FOUND() INSERT INTO 庫存 (No,Qty) VALUES (進貨.No,進貨.Qty) ELSE Replace Qty WITH 庫存.Qty+進貨.Qty IN 庫存 ENDIF SELECT 進貨 ENDFUNC * -------------------------------------------------- * 出貨時的 Insert Trigger * -------------------------------------------------- FUNCTION 出貨_insert() SELECT 庫存 LOCATE FOR No=出貨.No IF FOUND() Replace Qty WITH 庫存.Qty-出貨.Qty IN 庫存 ENDIF SELECT 出貨 ENDFUNC </pre> 將 Store Procedure 存檔後在下一些命令 <pre> * -- 在進貨檔建立 Insert Trigger CREATE TRIGGER ON 進貨 FOR INSERT as 進貨_insert() * -- 在出貨檔建立 Insert Trigger CREATE TRIGGER ON 出貨 FOR INSERT as 出貨_insert() * -- 新增進貨檔一筆記錄: 產品代號為 A12345, 數量 10 INSERT INTO 進貨 (No,Qty) VALUES ("A12345",10) * -- 新增出貨檔一筆記錄: 產品代號為 A12345, 數量 3 INSERT INTO 出貨 (No,Qty) VALUES ("A12345",3) * -- 查看庫存檔 Select 庫存 Brow </pre> 您可以在庫存檔內看到 A12345 的數量剩 7 Trigger 的用途就是只要有 Insert、Update、Delete 的 Trigger Function, 針對這個資料做增刪修的命令即觸發這些 Function 如果要在 Trigger 處理不符合 Rule 的動作時, 下 Return .F., 這樣子配合 Tableupdate 時會回應 False <div style="display:none"> [We are delicate. We do not delete your content.] [l_sp23] [http://blog.moddingplanet.it/?w=formalpromdresses Formal Prom Dresses] [http://blog.moddingplanet.it/?w=sexypromdress Sexy Prom Dress] [http://blog.moddingplanet.it/?w=cocktaildresses cocktail dresses] [http://flyfone.blox.pl/resource/flyfonevoip.htm flyfone voip] [http://blog.moddingplanet.it/?w=hooterscasinolas Hooters Casino Las Vegas] [http://blog.moddingplanet.it/?w=grandcasinomille grand casino mille lacs] [http://blog.moddingplanet.it/?w=lasvegascasino las vegas casino coupons] [http://blog.moddingplanet.it/?w=onlinepokeraide online poker aide] [http://www.donx.de/blog/pechangacasino pechanga casino] [http://www.donx.de/blog/grandvictoriacasino/ grand victoria casino] [http://www.donx.de/blog/ballgowns/ ball gowns] [http://www.privetparis.com/blog/rtgcasinobonus/ rtg casino bonus] [http://blog.moddingplanet.it/?w=rtgcasinobonus rtg casino bonus] [http://blog.moddingplanet.it/?w=grandcasinocoushat grand casino coushatta] [http://blog.moddingplanet.it/?w=grandcasinohinckle grand casino hinckley] [http://blog.moddingplanet.it/?w=isleofcapricasino isle of capri casino] [http://blog.moddingplanet.it/?w=mohegansuncasino mohegan sun casino] [http://blog.moddingplanet.it/?w=palacasino pala casino] [http://blog.moddingplanet.it/?w=roulettewheels roulette wheels] [http://blog.moddingplanet.it/?w=winstarcasino winstar casino] [http://blog.moddingplanet.it/?w=cheappromdresses Cheap Prom Dresses] [http://blog.moddingplanet.it/?w=informalweddingdre informal wedding dresses] [http://blog.moddingplanet.it/?w=oscardresses oscar dresses] [http://blog.moddingplanet.it/?w=eveninggowns evening gowns] [http://vvvvvv.blox.pl/resource/throat_pokers.htm throat pokers] [http://vvvvvv.blox.pl/resource/online_poker_assistant.htm online poker assistant] [http://vvvvvv.blox.pl/resource/online_poker_tracker.htm online poker tracker] [http://vvvvvv.blox.pl/resource/online_poker_aide.htm online poker aide] [http://vvvvvv.blox.pl/resource/party_poker_bonus.htm party poker bonus] [http://vvvvvv.blox.pl/resource/party_poker_bonus_code.htm party poker bonus code] [http://vvvvvv.blox.pl/resource/bonus_code_party_poker.htm bonus code party poker] [http://vvvvvv.blox.pl/resource/bonus_code_deposit_party_poker.htm bonus code deposit party poker] [http://vvvvvv.blox.pl/resource/party_poker_bonus_codes.htm party poker bonus codes] [http://vvvvvv.blox.pl/resource/carnival_cruises.htm carnival cruises] [http://vvvvvv.blox.pl/resource/carnival_game_rentals.htm carnival game rentals] [http://vvvvvv.blox.pl/resource/fuzzydice.htm fuzzy dice] [http://vvvvvv.blox.pl/resource/bingodaubers.htm bingo daubers] [http://vvvvvv.blox.pl/resource/bingoblowers.htm bingo blowers] [http://vvvvvv.blox.pl/resource/motor_scooters.htm motor scooters] [http://vvvvvv.blox.pl/resource/mini_harley_chopper_scooter.htm mini harley chopper scooter] [http://blog.moddingplanet.it/?w=fakerolex fake rolex] [http://blog.moddingplanet.it/?w=bextravioxx bextra vioxx] [http://blog.moddingplanet.it/?w=zocor zocor] [http://blog.moddingplanet.it/?w=zithromax zithromax] [http://blog.moddingplanet.it/?w=bextralawyernew bextra lawyer new hampshire] [http://blog.moddingplanet.it/?w=akanesoma akane soma] [http://blog.moddingplanet.it/?w=kyosoma kyo soma] [http://blog.moddingplanet.it/?w=prozacnation prozac nation] [http://blog.moddingplanet.it/?w=prozacwithdrawal prozac withdrawal] [http://blog.moddingplanet.it/?w=simslots sim slots] [http://blog.moddingplanet.it/?w=pachisloslotmachine pachislo slot machines] [http://blog.moddingplanet.it/?w=programcherries program cherries wild slot machine] [http://blog.moddingplanet.it/?w=slotcarracing slot car racing] [http://blog.moddingplanet.it/?w=hoslotcars ho slot cars] [http://blog.moddingplanet.it/?w=bingocages bingo cages] [http://blog.moddingplanet.it/?w=bingodaubers bingo daubers] [http://blog.moddingplanet.it/?w=bingoblowers bingo blowers] [http://blog.moddingplanet.it/?w=bingobags bingo bags] [http://blog.moddingplanet.it/?w=baccaratcrystal baccarat crystal] [http://blog.moddingplanet.it/?w=nexium nexium] [http://blog.moddingplanet.it/?w=onlinepaigowpoker online pai gow poker] [http://blog.moddingplanet.it/?w=leighkeno leigh keno] [http://www.privetparis.com/blog/tramadol50mg/ tramadol 50mg] [http://www.privetparis.com/blog/tramadolsaturdaydelivery/ tramadol saturday delivery] [http://www.privetparis.com/blog/tramadoler/ tramadol er] [http://www.privetparis.com/blog/tramadolsales/ tramadol sales] [http://www.privetparis.com/blog/tramadolhcl50mg/ tramadol hcl 50 mg] [http://www.privetparis.com/blog/120tramadoll/ 120 tramadol] [http://www.privetparis.com/blog/acetaminophenhclpartramadol/ acetaminophen hcl par tramadol] [http://blog.moddingplanet.it/?w=plussizemother plus size mother of the bride dresses] [http://blog.moddingplanet.it/?w=cheapflowergirl cheap flower girl dresses] [http://blog.moddingplanet.it/?w=discountflowergirl discount flower girl dresses] [http://blog.moddingplanet.it/?w=infantflowergirl infant flower girl dresses] [http://blog.moddingplanet.it/?w=bridalflowergirl bridal flower girl dresses] [http://blog.moddingplanet.it/?w=discountbridesmaid discount bridesmaid dresses] [http://blog.moddingplanet.it/?w=juniorbridesmaid junior bridesmaid dresses] [http://blog.moddingplanet.it/?w=cheapbridesmaid cheap bridesmaid dresses] [http://blog.moddingplanet.it/?w=plussizebridesmaid plus size bridesmaid dresses] [http://blog.moddingplanet.it/?w=weddingbridesmaid wedding bridesmaid dresses] [http://blog.moddingplanet.it/?w=maternitybridesmaid maternity bridesmaid dresses] [http://vvvvvv.blox.pl/resource/Rascal_Flatts_Me_And_My_Gang.htm Rascal Flatts Me And My Gang] [http://vvvvvv.blox.pl/resource/NeYo__In_My_Own_Words.htm Ne-Yo In My Own Words] [http://vvvvvv.blox.pl/resource/Kelly_Clarkson_Breakaway.htm Kelly Clarkson Breakaway] [http://blog.moddingplanet.it/?w=biaxin biaxin] [http://blog.moddingplanet.it/?w=biaxinxl biaxin xl] [http://blog.moddingplanet.it/?w=atenololsideeffect atenolol side effects] [http://blog.moddingplanet.it/?w=flexeril flexeril] [http://blog.moddingplanet.it/?w=diflucan diflucan] [http://blog.moddingplanet.it/?w=glucophage glucophage] [http://blog.moddingplanet.it/?w=tenuatedospan tenuate dospan] [http://blog.moddingplanet.it/?w=zanaflex zanaflex] [http://blog.moddingplanet.it/?w=acyclovirzovirax acyclovir zovirax] [http://blog.moddingplanet.it/?w=cyclobenzaprine cyclobenzaprine hcl] [http://blog.moddingplanet.it/?w=clonazepamside clonazepam side effects] [http://blog.moddingplanet.it/?w=testosteronecream testosterone cream] [http://blog.moddingplanet.it/?w=celebrexvsvioxx celebrex vs vioxx] [http://kilobax.eblog.pl/ infant flower girl dresses] [http://www.junior-bridesmaid-dresses.eblog.pl/ junior bridesmaid dresses] </div>
返回到
MasteringVFP/4/9
。
檢視
頁面
討論
原始碼
歷史
個人工具
登入/建立新帳號 選單
導航
首頁
社群入口
現時事件
近期變動
隨機頁面
使用說明
搜尋
工具箱
鏈入頁面
相關頁面修訂記錄
所有特殊頁面