Trigger Introduction

上一篇 / 下一篇  2005-03-16 00:00:00 / 个人分类:Oracle 开发文章

Introduction

A trigger is a compiled procedure stored in the database. The language you use is PL/SQL. You code and compile a trigger in the same manner you code stored procedures. The following is the SQL*Plus session that creates and demonstrates a simple Insert Row trigger. This trigger calls DBMS_OUTPUT to print "executing temp_air" for each row inserted.

SQL> set feedback off
SQL> CREATE TABLE temp (N NUMBER);
SQL> CREATE OR REPLACE TRIGGER temp_air
  2  AFTER INSERT ON TEMP
  3  FOR EACH ROW
  4  BEGIN
  5  dbms_output.put_line('executing temp_air');
  6  END;
7   /
8   SQL> INSERT INTO temp VALUES (1);      -- insert 1 row
executing temp_air
SQL> INSERT INTO temp SELECT * FROM temp;  -- insert 1 row
executing temp_air
SQL> INSERT INTO temp SELECT * FROM temp;  -- inserts 2 rows
executing temp_air
executing temp_air
SQL>

The third INSERT statement inserted two rows into TEMP, even though this was a single SQL statement. Most insert SQL statements insert a single row; however, as shown earlier, multiple rows can be inserted with one statement.



TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-08-30  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 1394
  • 日志数: 276
  • 图片数: 1
  • 建立时间: 2007-12-16
  • 更新时间: 2008-08-26

RSS订阅

Open Toolbar