This discussion is archived
3 Replies Latest reply: Jan 15, 2013 3:06 AM by 984919 RSS

based on Trigger

984919 Newbie
Currently Being Moderated
I have two table A & B with same columns.
I want to create insert trigger on table A such that it will add first 1-10 rows to table A & B as well.But next 11-100 rows should be inserted in table A only not in table B.
For next 101-110 rows should be added to table A & B as well and continue.

Can you please help me on this?
  • 1. Re: based on Trigger
    905265 Newbie
    Currently Being Moderated
    Hi,

    1. When insert is happening only for table A, i guess there is no need to think about 11-100 rows or similar numbers for table B insertion
    2. For the trigger part use the row count of the table and execute accordingly whether to insert a row in table B.
    3. Using the remainder logic will do the trick (1-10 divided by 100 - remainder 1-10)
    (11-100 divided by 100 - remainder (0,11-99)

    Same applies for values between 100-200 and so on


    Hope this helps

    Thanks,
    Sai
  • 2. Re: based on Trigger
    984919 Newbie
    Currently Being Moderated
    Thanks Sai.

    Can you please give me actual code for that trigger?

    But what if we have various users updating table A in various session and then how can v track it using rowcount?( if v r not allowed to take count(*) of table A or B)

    Thanks in Advance,
    Vrushali
  • 3. Re: based on Trigger
    984919 Newbie
    Currently Being Moderated
    Thanks Sai.

    Can you please give me actual code for that trigger?

    But what if we have various users updating table A in various session and then how can v track it using rowcount?( if v r not allowed to take count(*) of table A or B)

    Thanks in Advance,
    Vrushali

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points