日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle触发器转写成瀚高触发器

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle触发器转写成瀚高触发器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄
環境
文檔用途
詳細信息

環境
系統平臺:Microsoft Windows (64-bit) 10
版本:5.6.5
文檔用途
本文章主要介紹oracle觸發器轉換成瀚高的觸發器需要做哪些操作,主要修改哪些東西。

詳細信息
Oracle觸發器轉換為HighGoDB觸發器
1、創建觸發器函數

將Oracle觸發器的邏輯封裝成觸發器函數

2、創建觸發器

創建觸發器

創建觸發器函數
轉化為HighGoDB的觸發器,步驟:

第一步,將Oracle觸發器主邏輯封裝成HighGoDB觸發器函數

①、使用NEW替換:NEW,使用OLD 替換:OLD

②、函數返回類型為trigger最后return NEW 或者return NULL均可;

③、inserting updating deleting 替換成(TG_OP = ‘INSERT’) (TG_OP = ‘UPDATE’) (TG_OP = ‘DELETE’)

舉例:

oracle觸發器:

create or replace trigger "TRIG_ARCHIVE_HASTEN"before insert or delete or update on td_archive_hastenfor each rowdeclareisHasArchive number;beginif inserting or updating thenselect count(*)into isHasArchivefrom td_status_tempwhere businessid = :new.businessid;if (isHasArchive > 0) thenupdate td_status_tempset status = 1where businessid = :new.businessid;elseinsert into td_status_temp(businessid, status)values(:new.businessid, 1);end if;elsif deleting thenselect count(*)into isHasArchivefrom td_status_tempwhere businessid = :old.businessid;if (isHasArchive > 0) thenupdate td_status_tempset status = 1where businessid = :old.businessid;elseinsert into td_status_temp(businessid, status)values(:old.businessid, 1);end if;end if;end trig_archive_hasten;

轉換成瀚高后的語法:

create or replace function TRIG_ARCHIVE_HASTEN()returns triggeras $$declareisHasArchive number;beginif(TG_OP = 'INSERT') or (TG_OP = 'UPDATE') thenselect count(*)into isHasArchivefrom td_status_tempwhere businessid = new.businessid;if (isHasArchive > 0) thenupdate td_status_tempset status = 1where businessid = new.businessid;elseinsert into td_status_temp(businessid, status)values(new.businessid, 1);end if;elsif (TG_OP = 'DELETE') thenselect count(*)into isHasArchivefrom td_status_tempwhere businessid = old.businessid;if (isHasArchive > 0) thenupdate td_status_tempset status = 1where businessid = old.businessid;elseinsert into td_status_temp(businessid, status)values(old.businessid, 1);end if;end if;return new;end;$$ language plpgsql;

創建觸發器
第二步,創建觸發器

創建觸發器時,不需要replace 然后 on表直接 for each row execute procedure 加觸發器函數

create trigger TRIG_ARCHIVE_HASTENbefore insert or delete or update on td_archive_hastenfor each rowexecute procedure TRIG_ARCHIVE_HASTEN();

總結

以上是生活随笔為你收集整理的Oracle触发器转写成瀚高触发器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。