cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bulprosbibg
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
timl
Super User
Super User

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
timl
Super User
Super User

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

bulprosbibg
Frequent Visitor

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

bulprosbibg
Frequent Visitor

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,881)