Failed to create multiple Oracle triggers consecutively, a single creation is a successful workaround

Source: Internet
Author: User

When using a self-increment sequence, when a trigger is needed, I always report a compile pass, but there is a warning or an error when I create multiple triggers consecutively.

---1. Application Information drop TABLE app_info Cascade constraints;create table App_info (ID number (9) notNULL, AppID VARCHAR2 (255)defaultNULL, Appkey VARCHAR2 (255)defaultNULL, Md5_key VARCHAR2 (255)defaultNULL, Aes_key VARCHAR2 (255)defaultNULL, permission VARCHAR2 ( the)defaultNULL, email VARCHAR2 (255)defaultNULL, password VARCHAR2 (255)defaultNULL, Ras_public_key VARCHAR2 (255)defaultNULL, constraint App_info primary key (ID));d ROP sequence app_info_id;create sequence app_info_idincrement by1start with1Nomaxvaluenominvaluenocache; CREATE OR REPLACE TRIGGER addappinfo before INSERT on app_info for each ROW BEGIN SELECT app_info_id.nextval into: New. ID from dual; END; ---2. unit Info DROP TABLE unit_info Cascade constraints;create Table Unit_info (unit_id number (9) notNULL, USERID VARCHAR2 (255)defaultNULL, Unit_name VARCHAR2 ( -)defaultNULL, Unit_linkman VARCHAR2 ( -)defaultNULL, Organization_code VARCHAR2 ( -)defaultNULL, constraint Unit_info primary key (unit_id));d ROP sequence unit_info_id;create sequence Unit_info_idincrement b Y1start with1Nomaxvaluenominvaluenocache; CREATE OR REPLACE TRIGGER addunitinfo before INSERT on unit_info for each ROW BEGIN SELECT unit_info_id.nextval INT O:New. unit_id from dual; END; 

The error is as follows:

This creation is unsuccessful because the trigger needs to be compiled first, and each trigger needs to end with a "/" before the next one can be executed.

The right approach should be the case;

---1. Application Information drop TABLE app_info Cascade constraints;create table App_info (ID number (9) notNULL, AppID VARCHAR2 (255)defaultNULL, Appkey VARCHAR2 (255)defaultNULL, Md5_key VARCHAR2 (255)defaultNULL, Aes_key VARCHAR2 (255)defaultNULL, permission VARCHAR2 ( the)defaultNULL, email VARCHAR2 (255)defaultNULL, password VARCHAR2 (255)defaultNULL, Ras_public_key VARCHAR2 (255)defaultNULL, constraint App_info primary key (ID));d ROP sequence app_info_id;create sequence app_info_idincrement by1start with1Nomaxvaluenominvaluenocache; CREATE OR REPLACE TRIGGER addappinfo before INSERT on app_info for each ROW BEGIN SELECT app_info_id.nextval into: New. ID from dual; END; /---2. unit Info DROP TABLE unit_info Cascade constraints;create Table Unit_info (unit_id number (9) notNULL, USERID VARCHAR2 (255)defaultNULL, Unit_name VARCHAR2 ( -)defaultNULL, Unit_linkman VARCHAR2 ( -)defaultNULL, Organization_code VARCHAR2 ( -)defaultNULL, constraint Unit_info primary key (unit_id));d ROP sequence unit_info_id;create sequence Unit_info_idincrement b Y1start with1Nomaxvaluenominvaluenocache; CREATE OR REPLACE TRIGGER addunitinfo before INSERT on unit_info for each ROW BEGIN SELECT unit_info_id.nextval INT O:New. unit_id from dual; END; /

Note: The same is true for stored procedures.

Failed to create multiple Oracle triggers consecutively, a single creation is a successful workaround

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.