I have a temp table (question_desc, ans1, ans2, ans3, ans4, correct_ans, marks) with say 10 entries.
From this table I have to insert values in two other tables:
questions (q_id(auto-generated), que_desc, marks)
answers (ans_id(auto_generated), q_id(FK), ans_desc, istrue)
For each insert in questions table there should be four inserts in answers table and istrue bit will be set 1 for correct answer.
Like for question 1 with corr_ans 1, four entries will be
(1,1,djhjfj,1),
(2,1,hdjfsh,0),
(3,1,hsssh,0),
(4,1,jfsh,0)
After one row is inserted in questions table I need to fetch the q_id and use it while inserting 4 answer records.
I tried using insert trigger but it doesn’t work as it is statement level trigger, not row level. I am using SQL 2005. Please help.
Here is the basic idea, try to incorporate this into the rest of your app.