Primary key of one table to other while Importing

Hi all,

I am Importing an excel file to database. It has two tables Deals and Loans. Deals to Loans have one to many relationship and deal id should be stored in loans table for the related loans.

When I am uploading the file I am first storing the excel data in Datastore. And from data store I am saving the related data in the tables.

while saving the loans the related deal Id is not storing properly. Loans data is being saved from datastore itself. We are applying index for deals table and then storing the related deal ID in loans.

For example I have 10 deals of data in excel the first deal has one loan and the second deal has 3 loans and the third deal has one loan. For the first loan the dealId storing is 1 and for the next 3 loans the deal id is storing as 2 but for the 5th loan which belongs to 3rd deal the deal Id is storing as 5 instead of 3 in loans table.

The first picture code is used for getting the index. And the remaining two pictures is for storing the data in loans table.

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data