Official Content

The Unique Clause is optional in Data Provider Group statements, and allows you to determine which attributes musn't have duplicated values in the output.

See below an example where this clause could be used.

Consider the following Transaction objects:

Invoice                                                 
{                                                         
    InvoiceId*                                          
    InvoiceDate                                           
    CustomerId                                          
    CustomerName
    InvoiceDescription
    InvoiceTotal 
}

Customer
{
  CustomerId*
  CustomerName
}

Sample: Get the sales by date.

The output will be a Structured Data Type (SDT) object that is collection:

image_202451319308_1_png 

Drag and drop the "SalesByDate" Data Provider object from the KB Explorer to the Data Provider Source and complete the sourse as shown below:

SalesByDay from Invoice Unique InvoiceDate
{
   SalesByDayItem 
   {
      Day = InvoiceDate
      Total = sum(InvoiceTotal)
   }
}

Remember that in Data Providers repetitive groups loaded from database, it is exactly the same to declare the group Base Transaction, Order, Where, etc. at the outer group name (the collection one) or at the inner group name (the item itself). That is:

SalesByDay 
{
   SalesByDayItem  from Invoice Unique InvoiceDate
   {
      Day = InvoiceDate
      Total = sum(InvoiceTotal)
   }
}

See Also

Unique Clause

Last update: June 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant