contents   index   previous   next



SimpleDataset findDistinct()

syntax:

simpledataset.findDistinct(field)

where:

field - string indicating for which field duplicate values should be filtered out.

 

return:

boolean - value indicating success. In the case that the operation failed, use the getLastErrorCode() and getLastError() methods to determine the reason for the failure.

 

description:

This method removes all records from the SimpleDataset that have duplicate values for the indicated fields. In other words, for the given field, only one record with each value is left in the SimpleDataset.

 

Note that no guarantees are made as to which records are left in the SimpleDataset for each value of the field.

 

see:

#include <smdtset.jsh>, SimpleDataset find() with template, SimpleDataset find() with clause, SimpleDataset findAll()

 

example:

// print the unique country values

// in a SimpleDataset 

function unique_countries(db, table, user, passwd)

{

   var ds = new SimpleDataset(db, table, user,

                              passwd );

 

   // find the distinct country values

   ds.findDistinct( "country" );

 

   while( var rec = ds.nextRecord() )

      Clib.printf(var.country + "\n");

}

 


SimpleDataset addRecord()