web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using Collect to uploa...
Power Apps
Unanswered

Using Collect to upload multiple rows to PostgresSQL database with an auto-increment Primary Key

(0) ShareShare
ReportReport
Posted on by 8

I have a PostgresSQL database table with a Primary Key, set to Not Null, auto-increment, called "pricesid"

 

I generate a collection in Powerapps which mirrors the above table in terms of column headers, data types etc.  The only column that is different is the "pricesid" in my collection.

 

When I try and use the Collect function, it does not seem to be able to insert, without me defining values for the Primary Key.

 

If I do define values for the Primary Key, for example, setting them all initially to 0, then again the insert fails as they need to be unique.  I don't want to generate a set of values to then insert via Collect as multiple users may be inserting and there could be some overlap.

 

How do I get the Collect function to work, that seems to need to include the "pricesid" column?  It also won't let me set it to anything other than an integer as this is the data type.

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    What is the formula for your collection.

    Also are you using a Patch to insert the collection? if you can show the formula as well.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • cd30443 Profile Picture
    8 on at

    My database is called "fcpgf_prices" and my collection is called "newcoll".  I am using Collect rather than Patch as I was under tyhe impression this was more efficient, as they are new records to be inserted?

     

    Formula is straightforward but obviously I'm doing something fundamentally wrong!

     

    Collect('[fcpgf].[fcpgf_prices]',newcoll)

     

    Really appreciate the help!

  • eka24 Profile Picture
    20,923 on at

    Try this;

    ForAll(newcoll, Patch('[fcpgf].[fcpgf_prices]',
    Defaults('[fcpgf].[fcpgf_prices]'),
    {Column1: newcollColumn1,
    Column2: newcollColumn2,

    Column3: newcollColumn3
    }))

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • cd30443 Profile Picture
    8 on at

    thanks for the suggestion, I tried this and it still asks for the "pricesid" column to be included.  When I include it, I get the same issue as before.

  • Verified answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    Hi @cd30443 

    Unfortunately, there is a known bug/incompatibility between PowerApps and PostgresSQL tables with auto-increment primary keys.

    There are more details in my post here.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/MySQL-Auto-Increment-Primary-Key-Incompatibility/td-p/408532 

    As far as I know, there are no workarounds, except to remove the auto-increment PK.

  • cd30443 Profile Picture
    8 on at

    Ah, OK.  Thanks for the info!  Will work on an "auto-increment" in powerapps and remove from PK in the database.

     

    Do you know if it is a bug that is being worked on/fixed?

     

    Thanks

  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    @cd30443  - Unfortunately, I don't know if it's a bug that's being worked on/fixed. I imagine that the product team focus would be on CDS and SQL Server data sources, so I suspect this could be a low priority issue.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard