Table: T_users,t_user_except_work, where the primary key ID in t_users and the foreign key in T_user_except_work are sequence sequence_users. Currval's self-growth sequence.
More generally, insert a piece of data into the T_users table and insert a related data through the trigger at T_user_except_work.
Attention:
The sequence has the following two properties
Currval: Returns the current value of the sequence;
Nextval: Returns the value of the current sequence value increment by one step.
You can use the Currval property only after you have issued at least one nextval.
Note that the delay option is checked.
Create or Replace Trigger Trigger_user_except_work
After insert on T_users
For each row
Declare
--Local variables here
Begin
INSERT INTO T_user_except_work
(Id,except_city,except_position,job_categoryid,except_salaryid,userid)
Values
(Sequence_users. Currval, ', ', ', ', ', sequence_users. Currval);
End Trigger_user_except_work;
:
T_users table:
T_user_except_work table:
Implementing two data insertion problems for tables with primary foreign key relationships through triggers