Skip to main content
Feb 11, 2020 6:15 AM UTC
Solved

adding multiple entries in a datatable with the same primary key

I have a datatable with productname as primary key. i have two list widgets, one for product name and one for quantity. Now, for examples, if i select a product,say, a PCB and quantity as 2, then my datatable should make 2 entries having product name as PCB only. how do i do that? 

Feb 11, 2020 1:43 PM UTC

You should call Add service in the new service you are creating.

You can check also AddorUpdateDataTablesEntries (this is allowing you to add more than one entry in datatable).

 

Regards,

Raluca Edu

14 replies

Feb 11, 2020 6:46 AM UTC

Hello @gourinaik98,

 

If you use product name as primary key, you won't be able to insert two rows into your data table with the same product name. You should either insert one row with quantity = 2, or insert two rows, but use a combination of product name + quantity as your primary key.

 

/ Constantine

Feb 11, 2020 6:51 AM UTC
Can u elaborate on the latter option of using 2 primary keys?
Feb 11, 2020 7:22 AM UTC

It's a composite primary key rather than two different keys. Just check "Primary key" for two fields in your datashape.