I work in Fabric environment (Premium) and also have premium PowerApps license. I have a table in Fabric SQL Database. I created PowerApp which main purpose is to write data back to SQL db table (in fact update the value in a column). I added new SQL connection, created Gallery and added some TextInputs there. User puts value to TextInputs and value should be written back to SQL db table.
I select OnChange property in my TextInput and put this code:
Patch(db_table,
LookUp(db_table, product_id = ThisItem.product_id),
{product_price: Value(TextInput5.Text)})
product_id - this is my id column (string type), it's not PK (at least yet) product_price - column to update in sql table. It has float type. That's why I wrapped TextInput5 in Value(), just to make in number
Unfortunately, above function always shows this part highlighted:
Patch(db_table,
saying that:
The function Patch() has some invalid arguments.
I think that function doesn't miss any arguments. I also tried with this:
Value(Substitute(TextInput5.Text, ",", "."))
and this:
Value(Substitute(Self.Text, ",", "."))
but none of them works.
However, when I put3 cursos on LookUp function I have this type of warning:
LookUp(db_table, product_id = ThisItem.product_id) = This formula uses scope which is not presently supported for evaluation
It may suggest that I'm trying to use ThisItem outside the scope of a gallery but in fact my TextItem is 100% inside the gallery so I don't think it's an issue.
Need to mention that my TextInput has property Format set to Number. I also checked that I have write permissions on this table.
I've read that the reason could be that Patch() requires a table to have a PK but in fact official Microsoft docs don't mention it at all. But maybe here is the reason why. All in all, I don't know where the problem lies.
Check your db_table name , My table name is '[SalesLT].[Customer]' and it was causing issues in Patch function so I changed ITEMS property of my gallery to
'[SalesLT].[Customer]'As Cust
Below are screen shots from my sample app working with Fabric SQL Table. Below is image showing Customer table PK, But in my Patch function I used GUID field instead of Customer ID.
My Patch function said PasswordHash and PasswordSalt are required so I added them.
For updating field sin SQL Table, you can also use stored procedure. Below is SP I have created in Fabric Database.
Add connection for Stored procedure.
Add button in your gallery and call the SP.
SP will successfully update EMail address in database.