[Import] add data records in ASP. NET + Oracle and make ID auto Increment

Source: Internet
Author: User

Add data records in ASP. NET + Oracle and set the sequence and trigger in Oracle for automatic ID increment. Remember that the sequence is not an index. No matter the ID in ASP. NET, the details are as follows:
1. Create a sequence:
Create sequence seq_emergency_id
Nocycle
Max value 9999999999
Start with 2;

2. Create a trigger:
Create or replace trigger set_emergency_id
Before insert on "emergency"
For each row
Declare
Next_emergency_id number;
Begin
-- Get the next emergency ID from the sequence
Select seq_emergency_id.nextval
Into next_emergency_id
From dual;

-- Use the sequence number as the primary key
-- For the record being inserted
: New. ID: = next_emergency_id;
End;

If you create a trigger in Enterprise Manager, enter the following in the trigger description:
Declare
Next_emergencycb_id number;
Begin
-- Get the next ID number from the sequence
Select seq_emergencycb_id.nextval
Into next_emergencycb_id
From dual;

-- Use the sequence number as the primary key
-- For the record being inserted
: New. ID: = next_emergencycb_id;
End;

ArticleSource: http://dotnet.mblogger.cn/zeusvenus/posts/7258.aspx

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.