Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I am using PL/SQL developer and the database I am using is Oracle 11G R2 database with Visual Studio 2013. I use ODP.net as well.

Currently i load data for a set of Students using a stored proc e.g ClassNumber, Ethnicity etc. The data I load is dependent on what has been requested by the end user.

After i have loaded the data for the respctive students I would like to log the data for the requested students. Now currently the only way i know how to do it is to do a database call for each requested student by passing in a single StudentBioId and pass in the array of StudentBioIdentifiers. A StudentBioIdentifier is an identifier relating to the student information e.g ClassNumber, Ethnicity etc.

My original idea was to pass an array of StudentIds and array of StudentBioIds into the stored procedure but i wouldn't be able to relate the StudentBioId back to the Student because Student A may have Ethnicity value of XYZ but Student B could have ABC Ethnicity value. How can i work out which StudentBioId belongs to that Student without doing heavy select queries?

My goal is to make the data insertions faster, insert data correctly and potentially reduce database calls.

So currently the code in my stored proc looks like this:

SQL
CREATE OR REPLACE TYPE StudentBioIdArray IS VARRAY(100) OF NUMBER(2);

PROCEDURE InsertDummyStudentAuditData(studentID IN NUMBER, studentBioIds IN StudentBioIdArray) IS
BEGIN
  IF studentBioIds IS NOT NULL AND studentBioIds.Count > 0 THEN
  FORALL i IN 1..studentBioIds.COUNT
      INSERT INTO audit_table(Id, Student_id, StudentBioId) 
      VALUES  (-1, studentID, studentBioIds(i));
  END IF;
END InsertDummyStudentAuditData;


Questions
Even if i call the stored procedure for each student would it still be faster?
Is there a better alternative?
Posted
Updated 27-Jun-15 0:46am
v3

Check the below URL for details.

http://www.remote-dba.net/t_op_sql_insert_speed.htm[^]
 
Share this answer
 
@praveenlob7 thanks for the help.

For four of my Business Entities it was easier for me to do the Bulk Insert using the FORALL.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900