About Oracle's sequence and trigger.

Source: Internet
Author: User

For each self-increment field in MySQL, you need to create a sequence and a trigger in Oracle.

Even if there are X self-increment fields in the same table, you need to create X sequence and x and trigger.

In practice, I have built 915 sequence and 915 trigger. Because MySQL has 915 self-increment segments.

The resulting statements are as follows:

Create sequence seq_e3_910_yugou_goodsmx_id increment by 1 start with 1
MinValue 1
Nomaxvalue
NoCache
Order

And

Create trigger trigger_e3_910_yugou_goodsmx_i before insert on "Yugou_goodsmx"
For each row
Begin
Select Seq_e3_910_yugou_goodsmx_id.nextval into:new. " ID "from Sys.dual
;
End

There are 915 such pairs of statements appearing.

But the runtime, error ora-24344:success with compilation error. (Warning: A trigger was created with a compilation error.) )

So I only run create sequence, no problem, ran hundreds of.

If you run create trigger again, the error will be reported as above.

But I put these create trigger, in the Navicat single run, will be successful.

Check the long time, just know the reason is: http://www.2cto.com/database/201304/205599.html

Because triggers need to be compiled first, each trigger needs to end with "/" before the next one can be executed.

The following are instead:

Create trigger trigger_e3_910_yugou_goodsmx_i before insert on "Yugou_goodsmx"
For each row
Begin
Select Seq_e3_910_yugou_goodsmx_id.nextval into:new. " ID "from Sys.dual
;
End

/

Just run through multiple create trigger at once.

About Oracle's sequence and trigger.

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.