41
Views
4
Comments
How to make primary key autoGenerated when connecting to external database

Hi Folks,

I have an application connecting to external postgrelSQL database, and whenever I write SQL to insert a new row or use the build-in updateRow() function, and I need to generate a primaryKey manually which is really annoying. I am wondering if I can make the primary key auto generated, it will be much easier for me to develop.  Currently, the "Is Autogenerated" option is not selectable. Really appreciate any advice.


Champion

Hello

If you want to add the auto number please check this post.
https://www.outsystems.com/forums/discussion/62506/create-entity-does-not-return-identity-in-oracle-external-database/
You can go to Integration Studio click on the Table and Check the box 


Note : if it is text attribute, I think it will not work.

I hope this helps

Thanks


Hi Tousif,


Really appreciate your help, I made the change in integration studio, however, when I create new row without giving primary key myself, it throws this error: 
23502: null value in column "id" of relation "Consent" violates not-null constraint

Looks like the id is not autogenerated, may I have any suggestions? thanks! 

My updated setup is below:

when I insert new row, it gives:


Hi i am running into same problem , my server is mssql server, i have also enabled autogenerated as on in integration studio but still my id is stuck at zero , i don't know how to resolve

Hey GuoXin ,

You won't able to do now.This config should be set while creating the table.So I think you have two approach to resolve this

1)Create a new table with auto generated yes and make sure you set up auto generated field before the first publish.Now migrate the data and delete the older DB.

2)Create a server action named Create_Consent.Create a structure similar to your Consent entity but don't give the ID in the structure.Now Create a input variable for structure type.use CreateConsent Entity action into Create_Consent.


I think you must use the 2nd approach.

I am attaching an OML. This will definitely resolve your problem. 

Thanks & Regards,

Sudip Pal

Demo_Max.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.