Unix下Oracle8i中,编写实现如下功能的一个触发器,如何实现:
1、当对表A进行增删改操作时,触发它,拿出进行此操作的SQL语句,比如insert into a values('aaa',....),填写操作日志到Log表里。
2、当对表A进行增删改操作时,触发它,让它触发一个用C++编写的程序,可以传进参数最好。
在线等待!!!
1、当对表A进行增删改操作时,触发它,拿出进行此操作的SQL语句,比如insert into a values('aaa',....),填写操作日志到Log表里。
2、当对表A进行增删改操作时,触发它,让它触发一个用C++编写的程序,可以传进参数最好。
在线等待!!!
感觉好像在trigger下不能实现
帮你顶一下
但是通过审计功能觉得更简单一些
搜索‘audit’
设一个表为test,
SQL> desc test;
Name Type Nullable Default Comments
---- ------------ -------- ------- --------
AA NUMBER(10) Y
BB VARCHAR2(20) Y 可以用UTL_FILE包实现第一个功能,但是传入的参数有限,写入的log文件需要你整理一下:
create or replace trigger tri_test
before insert on test
for each row
declare
handle_file UTL_FILE.FILE_TYPE;
buf_file VARCHAR2(100); --没有用到
begin
handle_file :=UTL_FILE.FOPEN('F:\cn\','t.txt','w');
SYS.UTL_FILE.PUT_LINE(handle_file,'First Line Log'||:new.aa);
SYS.UTL_FILE.FCLOSE(handle_file);
end;
/
注意UTL_FILE包的使用方法(在init.ora中设置目录权限等)。
这样是否会简单一些
· from v$open_cursor
· where sid in (select sid from (select sid
· from v$session
· where status='ACTIVE'))用用上面这条语句,可能对你有帮助的,
它能找出当前已经激活的sql语句,
再查一下它的视图结构,可能对你有帮助。
(偶看一下先)
10
External Procedures
Well, if I called the wrong number, why did you answer the phone? James Thurber
PL/SQL is a powerful development tool; you can use it for almost any purpose. But, it is specialized for SQL transaction processing. So, some tasks are more quickly or easily done in a lower-level language such as C, which is more efficient at machine-precision calculations. For example, a Fast Fourier Transform (FFT) routine written in C runs faster than one written in PL/SQL. To support such special-purpose processing, PL/SQL provides an interface for calling routines written in other languages. This makes the strengths and capabilities of those languages available to you. No longer are you restricted to one language with its inherent limitations.
......
另外我是在9i的书上找的,没有那个函数,它是函数还是包的方法呀?