cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Insert records to SQL database

Hello,

 

I've just created 1 Power App with the following Run statement:

 

'PowerApp->Executestoredprocedure(V2)'.Run(Gallery1.Selected.DataLevelCode, Gallery1.Selected.AdjustmentLevelCode, Gallery1.Selected.LegalEntityCode, Gallery1.Selected.LegalEntityCurrency, Gallery1.Selected.FiscalYear, Gallery1.Selected.Period, Gallery1.Selected.TransactionCurrency, Gallery1.Selected.Value,Gallery1.Selected.Dim_GLAccount, Gallery1.Selected.Dim_CostCenter, Gallery1.Selected.Dim_LegalEntityPartner, Gallery1.Selected.Dim_TransactionType, Gallery1.Selected.PostingDescription)

 

This runs a Stored Procedure which write this data to SQL. The problem is that It writes only one line of data, but I selected more than one line.

 

For example, I selected 7 rows of data:

 

bulprosbibg_0-1593694698889.png

When I run the query only the first row is inseted (1,1,1,1,1....) into the database. Is it possible to insert all of the records (row 1 to row 7) in the database?

 

Thanks.

 

Best regards.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hi @bulprosbibg 

One way to do this is to call the ForAll function.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-forall 

If you want to call your Flow for each item in your gallery (eg 7 times), you can use code that looks like this:

ForAll(Gallery1.AllItems,
       'PowerApp->Executestoredprocedure(V2)'.Run(DataLevelCode, 
        AdjustmentLevelCode, LegalEntityCode, LegalEntityCurrency, 
        FiscalYear, Period, TransactionCurrency, Value,Dim_GLAccount, Dim_CostCenter, 
        Dim_LegalEntityPartner, Dim_TransactionType, PostingDescription)
)

 

View solution in original post

3 REPLIES 3
Super User III
Super User III

Hi @bulprosbibg 

One way to do this is to call the ForAll function.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-forall 

If you want to call your Flow for each item in your gallery (eg 7 times), you can use code that looks like this:

ForAll(Gallery1.AllItems,
       'PowerApp->Executestoredprocedure(V2)'.Run(DataLevelCode, 
        AdjustmentLevelCode, LegalEntityCode, LegalEntityCurrency, 
        FiscalYear, Period, TransactionCurrency, Value,Dim_GLAccount, Dim_CostCenter, 
        Dim_LegalEntityPartner, Dim_TransactionType, PostingDescription)
)

 

View solution in original post

You are gold! Thank you very much! For now this solved my problem!

Hello @timl 

 

This works fine, but now I have the following problem:

When I export the data from Power BI to SQL the inserted records are only 1,000. My data is more than 10,000 rows. Maybe there is some limitation becase the integration from Power BI, I dont know. Is there any work-around?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (7,648)