contents   index   previous   next

SimpleDataset find() with template


simpledataset.find(template1[, template2[, ...])


templateN - Item template to search for. When more than one template is present, the templates are OR'd together.


Templates contain properties to match. Only those records which have properties that match those values will be included in the result set.



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



This method searches the database table of a SimpleDataset for all items that match the given templates. The contents of the SimpleDataset are changed to reflect the results of the search. The previous contents of the SimpleDataset are cleared and the complete database table is searched to create the new contents.


After the find has completed, the current record is set to the record "before" the first record. Fill out the properties in the template to indicate which items to find. For instance, to find all records whose 'city' field equals "Metropolis", set the value of the 'city' property to "Metropolis". If a template has more than one property, the properties will be combined with an AND to form the search term.


More than one template can be used. If multiple templates are used, the template values will be combined using an OR to form the search term.



#include <smdtset.jsh>, SimpleDataset findAll(), SimpleDataset findDistinct(), SimpleDataset caseSensitive



// the following function will print out the fields

// of each of the records that have either Boston,

// USA or Paris, France as

// their city, country values

function print_BostonParis(db, table, user, passwd)


   // create the SimpleDataset

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



   var template1, template2; = "Boston"; = "USA"; = "Paris"; = "France";


   ds.find( template1, template2 );


   while( var rec = ds.nextRecord() )

      for( var prop in rec )

         Clib.printf(prop + " = " + rec[prop] +






SimpleDataset find() with clause