Import Excel to different tables in database

Hi all,

I have a requirement of importing the excel file to database. When the user upload an excel file in import it should create new data in 3 different tables.

For example, in the excel file the data present is based on deals and each deal can have one or more number of loans and the deal will be having some amount values. So when the user upload a file it should update deals table, loans table an other table which contains of amount data of the deal.

Thank you.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    We may need to use a two-step process for this requirement:

    1. **Upload to a Staging Table**: First, when the user uploads the Excel file, the entire data can be written to a temporary staging table. This ensures that the raw data from the Excel file is captured in a structured manner without directly affecting the main tables. Any validations or initial transformations can also be performed here.

    2. **Populate Data to Main Tables**: After the data is in the staging table, we can read the relevant information and populate the required main tables—such as the *deals* table, *loans* table, and a separate table for the deal amount values. The necessary business logic to relate deals and loans should be handled in this step.

    3. **Clear Staging Table**: Once the data is successfully written to the main tables, the staging table can be cleared, ensuring it's ready for the next upload 

  • Hey  ,

    I have tried but there are some date fields in the excel and when the file is uploaded the date fields are updating as null.

    Any Idea what to do here.

    Thank you.

  • As said in your other discussion post.

    Please change all the columns in the database table to varchar() then the import will succeed. And you will have all your data from excel in the staging table as text. Then you can manipulate the data as per your need.

Reply Children
  • Hi  ,

    I tried you approach and its working fine.

    But I am facing another issue in the process.

    When the file is uploaded the data is processing properly but for deals to loans table we have one to many relationship. so when we have multiple loans the deal id is not storing accordingly.

    The code is written based on index in deals record, but the data for loans we are using it from datastore so the index for deals is not proper.

    The above picture is for calculating Index.

    The above pictures are for loans.

    Can you help here.

    Thank you.