The best approach to create thousands of records in a trigge

Posted by ithrees on 14-Dec-2015 23:09

Hi All,

I have a situation that is to create around 3000 records in a trigger. In my system when I create a record with some information I need to create the reference records for all the students in the create trigger. What would be the best approach for this scenario?

If we are to use a batch job, is it possible to run a batch by calling from trigger with parameters?

Please advice,

Thanks in advance,
Ithrees. 

All Replies

Posted by Mani Kumar on 14-Dec-2015 23:33

Hi,

Please correct me if my understanding on this is not correct.

I understand that when you create record, you would want a trigger to create a reference/ related record?

If so, I guess you can use the " Run Triggers on Related Records" type trigger. For more information, please refer to below documentation:

documentation.progress.com/.../index.html

-Mani.

Posted by ithrees on 15-Dec-2015 00:40

Thank you Mani for you reply.

But my scenario is, say I have student, course and student-course objects in my system. Whenever I create a new course I have to create a student-course record for every student in the student object. I can simply do this by writing an after-create trigger for the course object. So this trigger will loop all the student records and will create student-course records for all the students.

This is working fine but my only worry is since I am expecting to handle around 3000 students in the system, What will happen when this trigger tries to create 3000 student-course records? Will there be timeout issue or performance issue or any other..?

Is there any better way to achieve this requirement something like running a batch job?

Ithrees

Posted by Thierry Ciot on 15-Dec-2015 14:57
Posted by ithrees on 17-Dec-2015 04:26

Thank you Theirry.

As the time taken to create all the records varies time to time I am using a batch job for the purpose. But my worry is for every record Im running a query to get some parameter values.

I think it would be good to have few things with batch job like,

 a calling mechanism to invoke a batch job from the scripts

 a way to keep common scripts without repeating the same for every record (like a header),

 a condition checking to decide whether to run or cancel the process.

Thank you all again.

Ithrees

This thread is closed