Primary Key Autogeneration Error (Using Extension)

Primary Key Autogeneration Error (Using Extension)

  

Hi,

I am using an extension on Outsystems to connect to a different server to the one that Outsystems is hosted on. 

The aim is to update the external SQL database with information that is inputted in Outsystems. This is done with a Create Run Server Action - an input parameter is used with a structure of the external SQl table.

However, the issue is that the Id field in Outsystems does not seem to be autogenerating a unique primary key and only generates NULL. This gives the following error:


Cannot insert the value NULL into column 'Id', table 'table'; column does not allow nulls. INSERT fails. The statement has been terminated.


I believe this is because the autogenerate key function from OS is not working correctly and is allocating 0 every time.  This functionality works in a replica of the app which does not use an extension and I have made sure all settings I can see are the same.

Any help would be greatly appreciated!


Thanks,


Craig

Craig, 

Are you "importing" the tables from the external database?

I think the autonumber is done database side, not in OutSystems. So, your external table must have its ID field set to be autonumber (or whatever it is called in SQL Server)  in order to this to work.

Solution

Jauch wrote:

Craig, 

Are you "importing" the tables from the external database?

I think the autonumber is done database side, not in OutSystems. So, your external table must have its ID field set to be autonumber (or whatever it is called in SQL Server)  in order to this to work.

Yes, you're right - thanks. I needed to alter my field SQL-side:

ALTER TABLE table DROP COLUMN Id

ALTER TABLE table ADD Id int IDENTITY(1,1) NOT NULL PRIMARY KEY


Solution