|
| 如何取得觸發 trigger 的 hostname or ip 2007/05/24 18:39 |
|
|
因異動某一table (t1) 的來源甚多, 現欲得知異動該table,甚至異動某一筆row的來源 hostname or ip, 於是以tigger方式去記錄, 但只能得知 username, 不知該如何得知 hostname or ip?
|
|
|
|
管理員已關閉公開寫入.
|
Paul Chang (用戶)
Junior Boarder
文章: 6
|
| 回覆:如何取得觸發 trigger 的 hostname or ip 2007/05/24 18:39 |
聲譽: 0   |
|
您可以在 trigger 中使用以下指令,得到SESSION ID select dbinfo ( 'sessionid' ) from systables where tabid = 1 再由 trigger 去呼叫 stored procedure, 由 stored procedure 中使用 system function 去執行外部程式! 由 外部程式抓出 hostname , IP ,然後 insert 到 table 中! 注意: stored procedure 呼叫外部程式時,外部程式不可以有output! 並且要加上 exit 0 Exp:
system("test.sh ; exit 0")
|
|
|
|
管理員已關閉公開寫入.
|
Eric Lam (用戶)
Senior Boarder
文章: 11
|
| 回覆:如何取得觸發 trigger 的 hostname or ip 2007/05/29 10:05 |
聲譽: 1   |
|
select hostname from sysmaster : syssessions where sid=dbinfo('sessionid')
但你要先定義 ip 及 hostname 至 /etc/hosts 檔, 不然你會得到 client IP 的 HEX 值
如. c0a87b64 即 192.168.123.100
另外, /etc/hosts 中的 hostname 不要超過 8 個 bytes
文章曾經由此用戶編輯: Eric Lam, 於: 2007/05/29 11:09
|
|
|
|
管理員已關閉公開寫入.
|
|