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