36
Views
4
Comments
Solved
File Upload from Excel to Create or Update Data in Entity

I have created a file upload feature that allows users to submit an Excel file containing, for example, only a category name. I can insert the data into the entity, but I would like to either update the existing data or avoid inserting it if a category with the same name already exists in the entity. Could anyone share an example of OML (Oracle Mapping Language) to update the data instead of creating new entries in the entity? 

2026-02-16 05-51-10
Sahana K
Solution

Hi @Jeremy Hui ,
1.Loop through the categories in the uploaded file
2.Check if the category exists in the database
Use an Aggregate with a filter Category.Name = ExcelCategory.Name.
3.Use an If condition 
If the aggregate result is empty, create a new category.
If it is not empty, update the existing record
4.Use CreateOrUpdateCategory Action:
If it exists, update its details.
If it doesn’t exist, insert a new record


Thanks,
sahana

2022-12-22 10-00-39
Beatriz Sabino
Solution

Hi Jeremy, 

I have attached an .oml file with two valid approaches to avoid inserting a record if a category with the same name already exists in the entity. 

ExelToRecordList_Example.oml
UserImage.jpg
Jeremy Hui

Thanks @Beatriz Sabino . this works for me!

2026-02-16 05-51-10
Sahana K
Solution

Hi @Jeremy Hui ,
1.Loop through the categories in the uploaded file
2.Check if the category exists in the database
Use an Aggregate with a filter Category.Name = ExcelCategory.Name.
3.Use an If condition 
If the aggregate result is empty, create a new category.
If it is not empty, update the existing record
4.Use CreateOrUpdateCategory Action:
If it exists, update its details.
If it doesn’t exist, insert a new record


Thanks,
sahana

2025-02-10 08-07-05
Sudha Narayanan

Hi @Jeremy Hui ,

If you want SQL-based logic, use an Advanced SQL query to do an Insert or Update.


UPDATE {Category}

SET Name = @CategoryName

WHERE Name = @CategoryName;

IF SQL%ROWCOUNT = 0 THEN   

INSERT INTO {Category} (Name)  

 VALUES (@CategoryName);

END IF;


@CategoryName  it defines the category name from Excel.

Thanks,

Sudha Narayanan 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.