SimpleDataset find() with clause
syntax: |
simpledataset.find(whereClause) |
where: |
whereClause - A string containing the WHERE clause of an SQL statement (without the word WHERE) indicating which items to find.
|
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 searches the database table of a SimpleDataset for all items that match the given SQL WHERE clause. 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.
The string passed into find contains a SQL WHERE clause. This allows more elaborate searches to be performed.
|
see: |
#include <smdtset.jsh>, SimpleDataset findAll(), SimpleDataset findDistinct()
|
example: |
// the following function will print out the fields // of each of the records that have either Boston // or Paris as their city values function print_BostonParis(db, table, user, passwd) { // create the SimpleDataset var ds = new SimpleDataset(db, table, user, passwd);
var whereClause;
whereClause = "(City = \'Boston\') OR (City = \'Paris\')";
ds.find(template1, template2);
while(var rec = ds.nextRecord()) for(var prop in rec) Clib.printf(prop + " = " + rec[prop] + "\n");
ds.close(); } |