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

Re: Insert records to SQL database

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

Re: Insert records to SQL database

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

Highlighted
Frequent Visitor

Re: Insert records to SQL database

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

Highlighted
Frequent Visitor

Re: Insert records to SQL database

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,016)