Home > Database > Mysql Tutorial > body text

创建表序列的触发器

WBOY
Release: 2016-06-07 15:27:59
Original
1394 people have browsed it

创建表序列的触发器 作用 直接往表中贴数据时让序列的字段自动生成 查看方法 一般为:1、触发器用户名.表名_TRG,view就能够看到相应的触发器的代码 2、通过view对应的表看到最后的trigger段可以看到enable的trigger 实现代码 create or replace trigger cux.c

 创建表序列的触发器 作用 直接往表中贴数据时让序列的字段自动生成 查看方法 一般为:1、触发器用户名.表名_TRG,view就能够看到相应的触发器的代码 2、通过view对应的表看到最后的trigger段可以看到enable的trigger 实现代码
create or replace trigger cux.cux_rebate_line_trg
 before insert on cux.cux_rebate_line for each row
declare
  l_id number;
begin
  select cux_rebate_line_s.nextval into :new.line_id from dual;
exception
  when others then
    raise_application_error(- 20100,
                            'get_sequence_nextval error' || sqlerrm );
end;
Copy after login
说明 1、创建的trigger需要创建在对应表的用户下面 2、命名上最好以:表名+_TRG 3、into的地方为:new.需要自动生成序列的列
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!